From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770499; cv=none; d=zohomail.com; s=zohoarc; b=MGl1SibsBB8D+lo1nJTzEQ4F0xCw93wsRMW9W+jyLFELuOsDBQ9CDfpqPs7hpXHo7za1tHnwD1pBo6YAMF6I75d3X1lk9ThOTGCiGLLrM+lHm0nhMv2dypIS+9Ol2vZK3kmQopKKiYCMmYqAeE7Ta6xy1Qd50A/GJPu7DzjwTGM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770499; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jTR0azPO570PZCFggyVak8jaWAO6whlTR6a7W48WgFQ=; b=bNG4fjAla6yEkEQQW543dfytbhgIlvgpiSTgctHL12dmDuHwDX03RhF7FuEG+VxUDw0dkdahkaa7bdKpaQqEUfFLedN6w8GjDCcwOjJrb33AZQCdUxruqr/fIRDuPGOXsp2L3iVQ1PoLS3/vmaXRtaZuMmoq7b4sNstVT5o5Xhw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770499599602.8037778076692; Tue, 3 Jan 2023 10:28:19 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrb-00009Q-EU; Tue, 03 Jan 2023 13:18:15 -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 1pClqM-0008Fg-9z for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:20 -0500 Received: from mail-yw1-x112d.google.com ([2607:f8b0:4864:20::112d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClqK-00056v-PM for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:16:58 -0500 Received: by mail-yw1-x112d.google.com with SMTP id 00721157ae682-3e45d25de97so447213447b3.6 for ; Tue, 03 Jan 2023 10:16:55 -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.16.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:16:54 -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=jTR0azPO570PZCFggyVak8jaWAO6whlTR6a7W48WgFQ=; b=L1/y+7Agns7IVeuJcr/dic2/cjMrxjhPjuHGCB0Yh/ylNwfmRwqDn1avwfvJOWuphy wXZIw4SzPf24VuLkUrY/BWXqafSAc6bSZWmNXqzFIqQ6qnYpyMRmnrH+tuUs+7HJg4iO dfoashWEc+HgqAt3FARxy01lqz+m+459obA28U6RJGXuBjUVIFVux9cF2Ue9R3Uyrzjw EnLwflSnak8JGP3wUMdxfTslR0Jn9y3Bcy0Dym1AHspVpklGz5rtvywRphnlkLycwOX9 Mh2fHCEniyaKueF9fAep7SlCOuWo+SsJmiu3db/h/IVXyE1OCdEYqKnL8nrSwBCSGdAc sm7g== 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=jTR0azPO570PZCFggyVak8jaWAO6whlTR6a7W48WgFQ=; b=igqqTg7jWaqLzz3a3iLcjo1fwqYW2znZeRNip1GcNFBOouIGhFTyWM8ZKeIDT5gJdT qGO7WoSw5rQx5OlD+XRzAQfxISCuZ+3YiQlNbUUErj4XoB8mVA+WiHrQKTHRIwYaQMi/ 8/oWViDTNcmgIkfrOsNQXoxJcpAgoa7XiBC+OglkTwn9WplkGaYA97VghG6fmhMN8ilX S+ms2Jb1K5eZmO6tELctqawFkIfS2fPzmarG+R4ZUxPiE+jiij381/eg3imX3F7WIMAk 8nJHIkUvwCPEwDJqpoUDmtMutAdPnValwLvWmtoPFdi8X9wnfqUVAAxwvsujsUzDM/61 Oyvw== X-Gm-Message-State: AFqh2kpHPw1ooSFcl3DRCz/UEWM+98+Bx8sbr74tgWR7rcBk8tXILlCz EM4NgVMmDStvZ44muw2252x1Vh1S11oR+R1d8ac= X-Google-Smtp-Source: AMrXdXufD40pHUkmmPWQVME8mYdKPLHjPqYpDcAJJNPI0ZcvarnvEVEYAHQ1fYi0OTH/rIvcUGCiNg== X-Received: by 2002:a05:690c:e1a:b0:46a:f5c0:7ba2 with SMTP id cp26-20020a05690c0e1a00b0046af5c07ba2mr36968769ywb.23.1672769814850; Tue, 03 Jan 2023 10:16:54 -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 01/40] qdev: Don't always force the global property array non-null Date: Tue, 3 Jan 2023 10:16:07 -0800 Message-Id: <20230103181646.55711-2-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::112d; envelope-from=richard.henderson@linaro.org; helo=mail-yw1-x112d.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770500085100009 Content-Type: text/plain; charset="utf-8" Only qdev_prop_register_global requires a non-null array. The other instances can simply exit early. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/core/qdev-properties.c | 43 ++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index 357b8761b5..f7775d0ea4 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -739,29 +739,31 @@ void qdev_prop_set_enum(DeviceState *dev, const char = *name, int value) &error_abort); } =20 -static GPtrArray *global_props(void) -{ - static GPtrArray *gp; - - if (!gp) { - gp =3D g_ptr_array_new(); - } - - return gp; -} +static GPtrArray *global_properties; =20 void qdev_prop_register_global(GlobalProperty *prop) { - g_ptr_array_add(global_props(), prop); + GPtrArray *props =3D global_properties; + + if (!props) { + props =3D g_ptr_array_new(); + global_properties =3D props; + } + + g_ptr_array_add(props, prop); } =20 const GlobalProperty *qdev_find_global_prop(Object *obj, const char *name) { - GPtrArray *props =3D global_props(); + GPtrArray *props =3D global_properties; const GlobalProperty *p; int i; =20 + if (!props) { + return NULL; + } + for (i =3D 0; i < props->len; i++) { p =3D g_ptr_array_index(props, i); if (object_dynamic_cast(obj, p->driver) @@ -774,14 +776,19 @@ const GlobalProperty *qdev_find_global_prop(Object *o= bj, =20 int qdev_prop_check_globals(void) { + GPtrArray *props =3D global_properties; int i, ret =3D 0; =20 - for (i =3D 0; i < global_props()->len; i++) { + if (!props) { + return 0; + } + + for (i =3D 0; i < props->len; i++) { GlobalProperty *prop; ObjectClass *oc; DeviceClass *dc; =20 - prop =3D g_ptr_array_index(global_props(), i); + prop =3D g_ptr_array_index(props, i); if (prop->used) { continue; } @@ -806,8 +813,12 @@ int qdev_prop_check_globals(void) =20 void qdev_prop_set_globals(DeviceState *dev) { - object_apply_global_props(OBJECT(dev), global_props(), - dev->hotplugged ? NULL : &error_fatal); + GPtrArray *props =3D global_properties; + + if (props) { + object_apply_global_props(OBJECT(dev), props, + dev->hotplugged ? NULL : &error_fatal); + } } =20 /* --- 64bit unsigned int 'size' type --- */ --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672769943; cv=none; d=zohomail.com; s=zohoarc; b=h1CqZPipxMJ+qgCMTUgocqD6aEhSJyo9dJGIudFkTA3sXE4mPCeUe3RSWoB/xw21nLQYigKFoXdx3YzomVq+G1foQxVqP63qtVn5fFjcG2hfVlaQzmmUt/crRDu3j3DNF9y8uV9m4jTDFmV3Pqu0ipJIgOnVbQciW1SBC1Yg+qE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672769943; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=J7OuKp2SIiYS9GaSHXxTFNZ32lT6tsgO1dGcaZ2HR4g=; b=UyTkJjZJIr3WCjqZvdhF+1NXidIK9pukU9+ELhX8oARFBaJjx8aaVDF8nJclDalPamMuryvjWDOjXf2r0iu+cfhLY76yEolQrPAi9rKjaKFB8rH2fGYrhki35Xs7hEW0L4or9YpR+luxMFPLRS2KvFY0RrN5+Wrayw4Td0d1TV0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672769943709774.1943803977379; Tue, 3 Jan 2023 10:19:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClra-00007I-IY; Tue, 03 Jan 2023 13:18:14 -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 1pClqO-0008Fh-Re for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:22 -0500 Received: from mail-vs1-xe30.google.com ([2607:f8b0:4864:20::e30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClqN-00057M-0l for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:00 -0500 Received: by mail-vs1-xe30.google.com with SMTP id l184so3937022vsc.0 for ; Tue, 03 Jan 2023 10:16:58 -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.16.55 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:16:57 -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=J7OuKp2SIiYS9GaSHXxTFNZ32lT6tsgO1dGcaZ2HR4g=; b=b871uOS6Xkw8z3HcmEedVNBPFlwD9FEUsYwcASN2ZtFtj/vjdRftO4kH84IjPXp3BP 27XZIxu9qLVkhWk6c/CiGibZHHCqjcHAQaiTKHPyxaf6Hmp+OozZ52ouDL4Ka7IygXzX EfZdip7SfMh5Qr9ErhoAVE/tHzNUwis16P8MpU5hqlRyp3c4/CXZCPEvPtwoK/Dzgb5k ffhAt0iYXk5Vwlpn5XYaI3KgY4ab6Kj64Dj0SiIum40b5rs1u6FoePfZYsmASQZ0OldG 3Us8A1zzKKAqUOcrku+r5zATMIuaak2kAeeraeR4tTqmdeFxuOsBB2gsgFeMUVKEeafN dhwQ== 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=J7OuKp2SIiYS9GaSHXxTFNZ32lT6tsgO1dGcaZ2HR4g=; b=R43fS63V3FcQESZufkswddkOiVnhkyuvG+vMRNC5Q+3aardDdDwAektGT/v/EHGtLk OjD30j51EVonGyqPILP9NhKCOp5PeQGzQXS5vZukzFm4VSSD6q+Erk7QJMZG8ZJVDTqD 5MJYhGkWvyNIAoM35svOOAHp3HdCegBen1BtdqejO2bsXqGPHEZx7yBOKw8SDggd6MaW Pmtr5zcQl1RYvFBDTnAaRnae7LNGoDvWX/sWeAxxWeW2Bq+cwI0eJ5Di/GqHrLoLBH+L /Kxdf968CYU03w5QMP7taUYjabdzFKxKEkS5CZptsjXwd53yyULUDqu3M8TOmce3XA7i LH7w== X-Gm-Message-State: AFqh2kq3RXdmKhsmZ/ztGCdsOkk4+dOdb+QO2/44iXa35TEUslDt1Ec9 uL0pee+g9RBgkXKiYSNEP5BGkoN4cpk7ay3Td64= X-Google-Smtp-Source: AMrXdXvDWvKm6K+MTUG8Ilkg+5tnNyDqD04NIEWu3pxa5d8qkJ7ll5uIiPWquq/yrUkkFX2xpAqJUw== X-Received: by 2002:a05:6102:3d26:b0:3b2:d3f2:63bd with SMTP id i38-20020a0561023d2600b003b2d3f263bdmr23125449vsv.29.1672769817811; Tue, 03 Jan 2023 10:16:57 -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 02/40] qom: Introduce class_late_init Date: Tue, 3 Jan 2023 10:16:08 -0800 Message-Id: <20230103181646.55711-3-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::e30; envelope-from=richard.henderson@linaro.org; helo=mail-vs1-xe30.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672769944586100003 Content-Type: text/plain; charset="utf-8" Create a new class initialization hook, to be called immediately before creation of the first instance. Most class initialization happens quite early, which makes interaction between classes difficult. E.g. cpu objects often depend on the accellerator, or the global properties coming from the command-line. Signed-off-by: Richard Henderson --- include/qom/object.h | 4 ++++ qom/object.c | 55 +++++++++++++++++++++++++++++++++++++------- 2 files changed, 51 insertions(+), 8 deletions(-) diff --git a/include/qom/object.h b/include/qom/object.h index ef7258a5e1..86958abe15 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -402,6 +402,9 @@ struct Object * parent class initialization has occurred, but before the class itself * is initialized. This is the function to use to undo the effects of * memcpy from the parent class to the descendants. + * @class_late_init: This function is called for all base classes just + * before the first object is created. This is the function to use to + * apply properties (which are interpreted quite late). * @class_data: Data to pass to the @class_init, * @class_base_init. This can be useful when building dynamic * classes. @@ -425,6 +428,7 @@ struct TypeInfo =20 void (*class_init)(ObjectClass *klass, void *data); void (*class_base_init)(ObjectClass *klass, void *data); + bool (*class_late_init)(ObjectClass *klass, Error **errp); void *class_data; =20 InterfaceInfo *interfaces; diff --git a/qom/object.c b/qom/object.c index e25f1e96db..82a5c7d36e 100644 --- a/qom/object.c +++ b/qom/object.c @@ -56,6 +56,7 @@ struct TypeImpl =20 void (*class_init)(ObjectClass *klass, void *data); void (*class_base_init)(ObjectClass *klass, void *data); + bool (*class_late_init)(ObjectClass *klass, Error **errp); =20 void *class_data; =20 @@ -64,6 +65,7 @@ struct TypeImpl void (*instance_finalize)(Object *obj); =20 bool abstract; + bool object_created; =20 const char *parent; TypeImpl *parent_type; @@ -121,6 +123,7 @@ static TypeImpl *type_new(const TypeInfo *info) =20 ti->class_init =3D info->class_init; ti->class_base_init =3D info->class_base_init; + ti->class_late_init =3D info->class_late_init; ti->class_data =3D info->class_data; =20 ti->instance_init =3D info->instance_init; @@ -367,6 +370,26 @@ static void type_initialize(TypeImpl *ti) } } =20 +static bool type_late_initialize(TypeImpl *ti, ObjectClass *cls, Error **e= rrp) +{ + TypeImpl *pi =3D type_get_parent(ti); + if (pi && !type_late_initialize(pi, cls, errp)) { + return false; + } + + for (GSList *e =3D ti->class->interfaces; e ; e =3D e->next) { + InterfaceClass *ic =3D e->data; + if (!type_late_initialize(ic->interface_type, cls, errp)) { + return false; + } + } + + if (ti->class_late_init) { + return ti->class_late_init(cls, errp); + } + return true; +} + static void object_init_with_type(Object *obj, TypeImpl *ti) { if (type_has_parent(ti)) { @@ -502,7 +525,8 @@ static void object_class_property_init_all(Object *obj) } } =20 -static void object_initialize_with_type(Object *obj, size_t size, TypeImpl= *type) +static bool object_initialize_with_type(Object *obj, size_t size, + TypeImpl *type, Error **errp) { type_initialize(type); =20 @@ -510,6 +534,13 @@ static void object_initialize_with_type(Object *obj, s= ize_t size, TypeImpl *type g_assert(type->abstract =3D=3D false); g_assert(size >=3D type->instance_size); =20 + if (!type->object_created) { + type->object_created =3D true; + if (!type_late_initialize(type, type->class, errp)) { + return false; + } + } + memset(obj, 0, type->instance_size); obj->class =3D type->class; object_ref(obj); @@ -518,6 +549,7 @@ static void object_initialize_with_type(Object *obj, si= ze_t size, TypeImpl *type NULL, object_property_free); object_init_with_type(obj, type); object_post_init_with_type(obj, type); + return true; } =20 void object_initialize(void *data, size_t size, const char *typename) @@ -540,7 +572,7 @@ void object_initialize(void *data, size_t size, const c= har *typename) abort(); } =20 - object_initialize_with_type(data, size, type); + object_initialize_with_type(data, size, type, &error_fatal); } =20 bool object_initialize_child_with_props(Object *parentobj, @@ -712,7 +744,7 @@ typedef union { } qemu_max_align_t; #endif =20 -static Object *object_new_with_type(Type type) +static Object *object_new_with_type(Type type, Error **errp) { Object *obj; size_t size, align; @@ -736,22 +768,25 @@ static Object *object_new_with_type(Type type) obj_free =3D qemu_vfree; } =20 - object_initialize_with_type(obj, size, type); - obj->free =3D obj_free; + if (!object_initialize_with_type(obj, size, type, errp)) { + obj_free(obj); + return NULL; + } =20 + obj->free =3D obj_free; return obj; } =20 Object *object_new_with_class(ObjectClass *klass) { - return object_new_with_type(klass->type); + return object_new_with_type(klass->type, &error_fatal); } =20 Object *object_new(const char *typename) { TypeImpl *ti =3D type_get_by_name(typename); =20 - return object_new_with_type(ti); + return object_new_with_type(ti, &error_fatal); } =20 =20 @@ -792,7 +827,11 @@ Object *object_new_with_propv(const char *typename, error_setg(errp, "object type '%s' is abstract", typename); return NULL; } - obj =3D object_new_with_type(klass->type); + + obj =3D object_new_with_type(klass->type, errp); + if (!obj) { + return NULL; + } =20 if (!object_set_propv(obj, errp, vargs)) { goto error; --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672769913; cv=none; d=zohomail.com; s=zohoarc; b=GdaO/Qj1YydCqDZMZ2IKEdzINyi4LPVA9cU2OnAwkT/hy1jNjrQpC7StQxlzbnI5zZHZybd/apm6g56G54vpYKIEE3x3jybQnMt9zq25IkT4gDnn7xJtF0XIWAa1bZwe5TrRjMeBT5dXc2q88LbrzWLYpFRy2cuykSSFrUogQWQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672769913; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=poMxRDPn366GZBea/9dCLSAffdWXTadkp9C7Z8GBPIw=; b=DfzOAroM+YD5afEmPvnMhzP2erN7ks1lxXvh5cJbAjfgcKNMji286SI3ml4qMuwCVNRxFYDvGNR95Ij0x3yaJhyc9Z8DoElWASKMdf58u9VF/HDaCE+5IcDiS9/Bkz9SMLU//vE3ZHJF/ZnEcGTHVN7cnHBDUjWFrHT1hCmlM5w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672769913319996.7855141766532; Tue, 3 Jan 2023 10:18:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrF-0008Lt-DO; Tue, 03 Jan 2023 13:17:53 -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 1pClqT-0008Fu-Eg for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:20 -0500 Received: from mail-vk1-xa2a.google.com ([2607:f8b0:4864:20::a2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClqQ-00057h-2K for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:04 -0500 Received: by mail-vk1-xa2a.google.com with SMTP id bk19so4768833vkb.11 for ; Tue, 03 Jan 2023 10:17:01 -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.16.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:00 -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=poMxRDPn366GZBea/9dCLSAffdWXTadkp9C7Z8GBPIw=; b=EhHns2BUCjMTPif02/2HFPX0/2nXbqiCJvTl9wtnSGwYvXjrzQimjlvliJWSLMmPvv 6E7BMMEI1KK5uWZ00an6oh95H8+wbUEk/wE2kXxFkSqRb18FFN8OzfcyZOmoX4XPlCWI o/CXLl8+Wf0tgNMKx01hrEWbxrdeajpOgHmkzwXb0JWds0xe7kGl8og5Oi0NZDySukiG qtR13mAASgzmUKqLx/2XASjoAkBL8728vEGoH//xnTZik9vjKYd803EeCMegnyQf5k36 yYNtQGBAEk2Peim2ARjSpHfoBFVzI5uUIIhh8jAa/gpn20nPd6t4dlNFw4DwbtN6AqR7 lRSQ== 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=poMxRDPn366GZBea/9dCLSAffdWXTadkp9C7Z8GBPIw=; b=2tAh8wJX4CIMfcvO9QycPGX+tG0oSKGZsj8ZFTiUaWdzpTJXpMr8+Ttzo7qVSjHF0e frYZxli8KlyIcth+bkpx7AliQcJ07WekHOLQ3RuWr4O7r0Zqx9F4EoXJf7bIpQxPhepk /t3TlqZXH5K3RVr2+VmyU6RugDDc5XC6PRMdHxMNsSQBIwKnAl2lBTDH6LsY2sJAlKYs r+hOtI1CHBTjMMFojBodDdB9v05hjhhlMg3mBuCcV/tkH+cijMlSaCEpfv3hqZ2d3Mq2 NvVsF0fxb0X7uREjdiOXJsc9kMBgUCGAerRPNrk17ohw6w6/7GUBUuTSSCJDkdHOWTbo SACg== X-Gm-Message-State: AFqh2krM4mKG2U8H0v5xHCj2KRM6NMpU/KthB2mPks+ZbjUy2pdDzh3+ dYW1KlnSMzzgKEVO7PQSES4HMB4RRNgpffkf8Vg= X-Google-Smtp-Source: AMrXdXtHUMzmtvsM5YbzCrdLPmwf3TsLDbFoyKichdhHRwGXyHxwT/dkeSPDP3gNesplAq6rerhv3A== X-Received: by 2002:a1f:bdcf:0:b0:3d5:6850:70ac with SMTP id n198-20020a1fbdcf000000b003d5685070acmr13190791vkf.13.1672769820779; Tue, 03 Jan 2023 10:17:00 -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 03/40] qom: Create class properties Date: Tue, 3 Jan 2023 10:16:09 -0800 Message-Id: <20230103181646.55711-4-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::a2a; envelope-from=richard.henderson@linaro.org; helo=mail-vk1-xa2a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672769914538100003 Content-Type: text/plain; charset="utf-8" These properties apply to the class itself, as opposed to object_class_property_* in which the property is attached to the class but applies to each object instance. Apply global properties via a class_late_init on DeviceClass. Signed-off-by: Richard Henderson --- hw/core/qdev-prop-internal.h | 2 + include/qom/object.h | 63 ++++++++++++ include/qom/qom-qobject.h | 28 +++++ hw/core/cpu-common.c | 61 ++++++++--- hw/core/qdev-properties.c | 36 +++++++ hw/core/qdev.c | 2 + qom/object.c | 194 +++++++++++++++++++++++++++++++++++ qom/object_interfaces.c | 13 +++ qom/qom-qmp-cmds.c | 37 +++++++ 9 files changed, 419 insertions(+), 17 deletions(-) diff --git a/hw/core/qdev-prop-internal.h b/hw/core/qdev-prop-internal.h index d7b77844fe..21cd3bca27 100644 --- a/hw/core/qdev-prop-internal.h +++ b/hw/core/qdev-prop-internal.h @@ -25,4 +25,6 @@ void qdev_propinfo_get_int32(Object *obj, Visitor *v, con= st char *name, void qdev_propinfo_get_size32(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp); =20 +bool device_class_late_init(ObjectClass *class, Error **errp); + #endif diff --git a/include/qom/object.h b/include/qom/object.h index 86958abe15..caa4774f80 100644 --- a/include/qom/object.h +++ b/include/qom/object.h @@ -27,8 +27,25 @@ typedef struct InterfaceInfo InterfaceInfo; =20 #define TYPE_OBJECT "object" =20 +typedef struct ClassProperty ClassProperty; typedef struct ObjectProperty ObjectProperty; =20 +/** + * typedef ClassPropertyAccessor: + * @klass: the class that owns the property + * @v: the visitor that contains the property data + * @name: the name of the property + * @opaque: the class property opaque + * @errp: a pointer to an Error that is filled if getting/setting fails. + * + * Called when trying to get/set a property. + */ +typedef bool (ClassPropertyAccessor)(ObjectClass *klass, + Visitor *v, + const char *name, + void *opaque, + Error **errp); + /** * typedef ObjectPropertyAccessor: * @obj: the object that owns the property @@ -85,6 +102,16 @@ typedef void (ObjectPropertyRelease)(Object *obj, */ typedef void (ObjectPropertyInit)(Object *obj, ObjectProperty *prop); =20 +struct ClassProperty +{ + char *name; + char *type; + char *description; + ClassPropertyAccessor *get; + ClassPropertyAccessor *set; + void *opaque; +}; + struct ObjectProperty { char *name; @@ -135,6 +162,7 @@ struct ObjectClass =20 ObjectUnparent *unparent; =20 + GHashTable *class_properties; GHashTable *properties; }; =20 @@ -1072,6 +1100,11 @@ ObjectProperty *object_property_add(Object *obj, con= st char *name, =20 void object_property_del(Object *obj, const char *name); =20 +/** + * object_class_property_add: + * + * Add a property to the class, as if added to each object instance. + */ ObjectProperty *object_class_property_add(ObjectClass *klass, const char *= name, const char *type, ObjectPropertyAccessor *get, @@ -1079,6 +1112,33 @@ ObjectProperty *object_class_property_add(ObjectClas= s *klass, const char *name, ObjectPropertyRelease *release, void *opaque); =20 +/** + * class_property_add: + * + * Add a property to the class, affecting the class as a whole + * rather than each instance. All such properties are resolved + * before the first object instance is created. + */ +void class_property_add(ObjectClass *klass, const char *name, + const char *type, const char *desc, + ClassPropertyAccessor *get, + ClassPropertyAccessor *set, + void *opaque); + +ClassProperty *class_property_find(ObjectClass *klass, const char *name); + +bool class_property_set(ObjectClass *klass, ClassProperty *cp, + Visitor *v, Error **errp); +bool class_property_set_bool(ObjectClass *klass, const char *name, + bool value, Error **errp); +bool class_property_set_uint(ObjectClass *klass, const char *name, + uint64_t value, Error **errp); + +bool class_property_get(ObjectClass *klass, ClassProperty *cp, + Visitor *v, Error **errp); +bool class_property_get_bool(ObjectClass *klass, const char *name, + Error **errp); + /** * object_property_set_default_bool: * @prop: the property to set @@ -1229,6 +1289,9 @@ void object_class_property_iter_init(ObjectPropertyIt= erator *iter, */ ObjectProperty *object_property_iter_next(ObjectPropertyIterator *iter); =20 +void class_property_iter_init(ObjectPropertyIterator *iter, ObjectClass *k= lass); +ClassProperty *class_property_iter_next(ObjectPropertyIterator *iter); + void object_unparent(Object *obj); =20 /** diff --git a/include/qom/qom-qobject.h b/include/qom/qom-qobject.h index 73e4e0e474..4026fe6964 100644 --- a/include/qom/qom-qobject.h +++ b/include/qom/qom-qobject.h @@ -40,4 +40,32 @@ bool object_property_set_qobject(Object *obj, const char *name, struct QObject *value, struct Error **errp); =20 +/* + * class_property_get_qobject: + * @cls: the class object + * @name: the name of the property + * @errp: returns an error if this function fails + * + * Returns: the value of the property, converted to QObject, or NULL if + * an error occurs. + */ +struct QObject *class_property_get_qobject(ObjectClass *cls, + const char *name, + struct Error **errp); + +/** + * class_property_set_qobject: + * @cls: the class object + * @name: the name of the property + * @value: The value that will be written to the property. + * @errp: returns an error if this function fails + * + * Writes a property to a class object. + * + * Returns: %true on success, %false on failure. + */ +bool class_property_set_qobject(ObjectClass *cls, + const char *name, struct QObject *value, + struct Error **errp); + #endif diff --git a/hw/core/cpu-common.c b/hw/core/cpu-common.c index 78b5f350a0..34cab4ef31 100644 --- a/hw/core/cpu-common.c +++ b/hw/core/cpu-common.c @@ -34,6 +34,7 @@ #include "hw/qdev-properties.h" #include "trace/trace-root.h" #include "qemu/plugin.h" +#include "qapi/string-input-visitor.h" =20 CPUState *cpu_by_arch_id(int64_t id) { @@ -158,31 +159,57 @@ ObjectClass *cpu_class_by_name(const char *typename, = const char *cpu_model) static void cpu_common_parse_features(const char *typename, char *features, Error **errp) { - char *val; static bool cpu_globals_initialized; - /* Single "key=3Dvalue" string being parsed */ - char *featurestr =3D features ? strtok(features, ",") : NULL; + ObjectClass *klass; + char *f; =20 /* should be called only once, catch invalid users */ assert(!cpu_globals_initialized); cpu_globals_initialized =3D true; =20 - while (featurestr) { - val =3D strchr(featurestr, '=3D'); - if (val) { - GlobalProperty *prop =3D g_new0(typeof(*prop), 1); - *val =3D 0; - val++; - prop->driver =3D typename; - prop->property =3D g_strdup(featurestr); - prop->value =3D g_strdup(val); - qdev_prop_register_global(prop); - } else { - error_setg(errp, "Expected key=3Dvalue format, found %s.", - featurestr); + if (!features) { + return; + } + + /* + * If typename is invalid, we'll register the global properties anyway + * and report a warning in qdev_prop_check_globals. + * TODO: Report an error early if -cpu typename is invalid; all classes + * will have been registered by now, whether or not the target is using + * class properties or object properties. + */ + klass =3D object_class_by_name(typename); + + /* Single "key=3Dvalue" string being parsed */ + for (f =3D strtok(features, ","); f !=3D NULL; f =3D strtok(NULL, ",")= ) { + char *val =3D strchr(f, '=3D'); + GlobalProperty *prop; + + if (!val) { + error_setg(errp, "Expected key=3Dvalue format, found %s.", f); return; } - featurestr =3D strtok(NULL, ","); + *val++ =3D 0; + + if (klass) { + ClassProperty *cp =3D class_property_find(klass, f); + if (cp) { + Visitor *v =3D string_input_visitor_new(val); + bool ok =3D class_property_set(klass, cp, v, errp); + + visit_free(v); + if (!ok) { + return; + } + continue; + } + } + + prop =3D g_new0(typeof(*prop), 1); + prop->driver =3D typename; + prop->property =3D g_strdup(f); + prop->value =3D g_strdup(val); + qdev_prop_register_global(prop); } } =20 diff --git a/hw/core/qdev-properties.c b/hw/core/qdev-properties.c index f7775d0ea4..30037ddfb2 100644 --- a/hw/core/qdev-properties.c +++ b/hw/core/qdev-properties.c @@ -6,6 +6,7 @@ #include "qemu/ctype.h" #include "qemu/error-report.h" #include "qapi/visitor.h" +#include "qapi/string-input-visitor.h" #include "qemu/units.h" #include "qemu/cutils.h" #include "qdev-prop-internal.h" @@ -821,6 +822,41 @@ void qdev_prop_set_globals(DeviceState *dev) } } =20 +bool device_class_late_init(ObjectClass *class, Error **errp) +{ + GPtrArray *props =3D global_properties; + int i, len =3D props ? props->len : 0; + + for (i =3D 0; i < len; i++) { + GlobalProperty *p =3D g_ptr_array_index(props, i); + ClassProperty *cp; + Visitor *v; + bool ok; + + if (object_class_dynamic_cast(class, p->driver) =3D=3D NULL) { + continue; + } + + cp =3D class_property_find(class, p->property); + if (!cp) { + /* The property may be on the object. */ + continue; + } + p->used =3D true; + + v =3D string_input_visitor_new(p->value); + ok =3D class_property_set(class, cp, v, errp); + visit_free(v); + + if (!ok) { + error_prepend(errp, "can't apply global %s.%s=3D%s: ", + p->driver, p->property, p->value); + return false; + } + } + return true; +} + /* --- 64bit unsigned int 'size' type --- */ =20 static void get_size(Object *obj, Visitor *v, const char *name, void *opaq= ue, diff --git a/hw/core/qdev.c b/hw/core/qdev.c index d759c4602c..772aedc914 100644 --- a/hw/core/qdev.c +++ b/hw/core/qdev.c @@ -40,6 +40,7 @@ #include "hw/qdev-clock.h" #include "migration/vmstate.h" #include "trace.h" +#include "qdev-prop-internal.h" =20 static bool qdev_hot_added =3D false; bool qdev_hot_removed =3D false; @@ -901,6 +902,7 @@ static const TypeInfo device_type_info =3D { .instance_finalize =3D device_finalize, .class_base_init =3D device_class_base_init, .class_init =3D device_class_init, + .class_late_init =3D device_class_late_init, .abstract =3D true, .class_size =3D sizeof(DeviceClass), .interfaces =3D (InterfaceInfo[]) { diff --git a/qom/object.c b/qom/object.c index 82a5c7d36e..344ca03877 100644 --- a/qom/object.c +++ b/qom/object.c @@ -21,6 +21,7 @@ #include "qapi/string-input-visitor.h" #include "qapi/string-output-visitor.h" #include "qapi/qobject-input-visitor.h" +#include "qapi/qobject-output-visitor.h" #include "qapi/forward-visitor.h" #include "qapi/qapi-builtin-visit.h" #include "qapi/qmp/qerror.h" @@ -34,6 +35,7 @@ #include "qapi/qmp/qnum.h" #include "qapi/qmp/qstring.h" #include "qemu/error-report.h" +#include "sysemu/qtest.h" =20 #define MAX_INTERFACES 32 =20 @@ -76,6 +78,190 @@ struct TypeImpl InterfaceImpl interfaces[MAX_INTERFACES]; }; =20 +ClassProperty *class_property_find(ObjectClass *klass, const char *name) +{ + ObjectClass *parent_klass; + + if (klass->class_properties) { + ClassProperty *p =3D g_hash_table_lookup(klass->class_properties, = name); + if (p) { + return p; + } + } + + parent_klass =3D object_class_get_parent(klass); + if (parent_klass) { + return class_property_find(parent_klass, name); + } + return NULL; +} + +static ClassProperty *class_property_find_err(ObjectClass *klass, + const char *name, + Error **errp) +{ + ClassProperty *cp =3D class_property_find(klass, name); + if (!cp) { + error_setg(errp, "Property '%s.%s' not found", + klass->type->name, name); + } + return cp; +} + +void class_property_add(ObjectClass *klass, const char *name, + const char *type, const char *desc, + ClassPropertyAccessor *get, + ClassPropertyAccessor *set, + void *opaque) +{ + ClassProperty *prop; + + assert(!class_property_find(klass, name)); + + prop =3D g_new0(ClassProperty, 1); + + prop->name =3D g_strdup(name); + prop->type =3D g_strdup(type); + prop->description =3D g_strdup(desc); + + prop->get =3D get; + prop->set =3D set; + prop->opaque =3D opaque; + + if (!klass->class_properties) { + klass->class_properties =3D g_hash_table_new(g_str_hash, g_str_equ= al); + } + g_hash_table_insert(klass->class_properties, prop->name, prop); +} + +bool class_property_set(ObjectClass *klass, ClassProperty *cp, + Visitor *v, Error **errp) +{ + /* + * FIXME: qtest/device-introspect-test creates one of each board, + * inside the same qemu instance. The class properties for the + * cpus may well be adjusted for each board. This cannot happen + * during normal usage. + */ + if (!qtest_enabled() && klass->type->object_created) { + error_setg(errp, "Property '%s.%s' set after object creation", + klass->type->name, cp->name); + return false; + } + return cp->set(klass, v, cp->name, cp->opaque, errp); +} + +static bool class_property_set_lookup(ObjectClass *klass, const char *name, + Visitor *v, Error **errp) +{ + ClassProperty *cp =3D class_property_find_err(klass, name, errp); + if (!cp) { + return false; + } + return class_property_set(klass, cp, v, errp); +} + +bool class_property_set_qobject(ObjectClass *klass, const char *name, + QObject *value, Error **errp) +{ + Visitor *v =3D qobject_input_visitor_new(value); + bool ok; + + ok =3D class_property_set_lookup(klass, name, v, errp); + visit_free(v); + return ok; +} + +bool class_property_set_bool(ObjectClass *klass, const char *name, + bool value, Error **errp) +{ + QBool *qbool =3D qbool_from_bool(value); + bool ok; + + ok =3D class_property_set_qobject(klass, name, QOBJECT(qbool), errp); + qobject_unref(qbool); + return ok; +} + +bool class_property_set_uint(ObjectClass *klass, const char *name, + uint64_t value, Error **errp) +{ + QNum *qnum =3D qnum_from_uint(value); + bool ok; + + ok =3D class_property_set_qobject(klass, name, QOBJECT(qnum), errp); + qobject_unref(qnum); + return ok; +} + +bool class_property_get(ObjectClass *klass, ClassProperty *cp, + Visitor *v, Error **errp) +{ + return cp->get(klass, v, cp->name, cp->opaque, errp); +} + +static bool class_property_get_lookup(ObjectClass *klass, const char *name, + Visitor *v, Error **errp) +{ + ClassProperty *cp =3D class_property_find_err(klass, name, errp); + if (!cp) { + return false; + } + return class_property_get(klass, cp, v, errp); +} + + +QObject *class_property_get_qobject(ObjectClass *klass, const char *name, + Error **errp) +{ + QObject *ret =3D NULL; + Visitor *v =3D qobject_output_visitor_new(&ret); + + if (class_property_get_lookup(klass, name, v, errp)) { + visit_complete(v, &ret); + } + visit_free(v); + return ret; +} + +bool class_property_get_bool(ObjectClass *klass, const char *name, + Error **errp) +{ + QObject *qobj =3D class_property_get_qobject(klass, name, errp); + bool ret =3D false; + + if (qobj) { + QBool *qbool =3D qobject_to(QBool, qobj); + if (!qbool) { + error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "boolean"); + } else { + ret =3D qbool_get_bool(qbool); + } + qobject_unref(qobj); + } + return ret; +} + +void class_property_iter_init(ObjectPropertyIterator *iter, + ObjectClass *klass) +{ + g_hash_table_iter_init(&iter->iter, klass->class_properties); + iter->nextclass =3D object_class_get_parent(klass); +} + +ClassProperty *class_property_iter_next(ObjectPropertyIterator *iter) +{ + gpointer key, val; + while (!g_hash_table_iter_next(&iter->iter, &key, &val)) { + if (!iter->nextclass) { + return NULL; + } + g_hash_table_iter_init(&iter->iter, iter->nextclass->class_propert= ies); + iter->nextclass =3D object_class_get_parent(iter->nextclass); + } + return val; +} + static Type type_interface; =20 static GHashTable *type_table_get(void) @@ -322,6 +508,7 @@ static void type_initialize(TypeImpl *ti) g_assert(parent->instance_size <=3D ti->instance_size); memcpy(ti->class, parent->class, parent->class_size); ti->class->interfaces =3D NULL; + ti->class->class_properties =3D NULL; =20 for (e =3D parent->class->interfaces; e; e =3D e->next) { InterfaceClass *iface =3D e->data; @@ -415,12 +602,15 @@ static void object_post_init_with_type(Object *obj, T= ypeImpl *ti) bool object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp) { + ObjectClass *klass; int i; =20 if (!props) { return true; } =20 + klass =3D object_get_class(obj); + for (i =3D 0; i < props->len; i++) { GlobalProperty *p =3D g_ptr_array_index(props, i); Error *err =3D NULL; @@ -428,6 +618,10 @@ bool object_apply_global_props(Object *obj, const GPtr= Array *props, if (object_dynamic_cast(obj, p->driver) =3D=3D NULL) { continue; } + if (class_property_find(klass, p->property)) { + /* This was handled in device_class_late_init. */ + continue; + } if (p->optional && !object_property_find(obj, p->property)) { continue; } diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index f94b6c3193..aee86eb708 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -203,6 +203,7 @@ bool type_print_class_properties(const char *type) ObjectClass *klass; ObjectPropertyIterator iter; ObjectProperty *prop; + ClassProperty *cprop; GPtrArray *array; int i; =20 @@ -212,6 +213,7 @@ bool type_print_class_properties(const char *type) } =20 array =3D g_ptr_array_new(); + object_class_property_iter_init(&iter, klass); while ((prop =3D object_property_iter_next(&iter))) { if (!prop->set) { @@ -222,6 +224,17 @@ bool type_print_class_properties(const char *type) object_property_help(prop->name, prop->type, prop->defval, prop->descripti= on)); } + + class_property_iter_init(&iter, klass); + while ((cprop =3D class_property_iter_next(&iter))) { + if (!cprop->set) { + continue; + } + g_ptr_array_add(array, + object_property_help(cprop->name, cprop->type, + NULL, cprop->description)); + } + g_ptr_array_sort(array, (GCompareFunc)qemu_pstrcmp0); if (array->len > 0) { qemu_printf("%s options:\n", type); diff --git a/qom/qom-qmp-cmds.c b/qom/qom-qmp-cmds.c index 7c087299de..ea3f542a1d 100644 --- a/qom/qom-qmp-cmds.c +++ b/qom/qom-qmp-cmds.c @@ -34,6 +34,7 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Er= ror **errp) bool ambiguous =3D false; ObjectPropertyInfoList *props =3D NULL; ObjectProperty *prop; + ClassProperty *cprop; ObjectPropertyIterator iter; =20 obj =3D object_resolve_path(path, &ambiguous); @@ -57,6 +58,16 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, E= rror **errp) value->type =3D g_strdup(prop->type); } =20 + class_property_iter_init(&iter, object_get_class(obj)); + while ((cprop =3D class_property_iter_next(&iter))) { + ObjectPropertyInfo *value =3D g_new0(ObjectPropertyInfo, 1); + + QAPI_LIST_PREPEND(props, value); + + value->name =3D g_strdup(cprop->name); + value->type =3D g_strdup(cprop->type); + } + return props; } =20 @@ -124,6 +135,7 @@ ObjectPropertyInfoList *qmp_device_list_properties(cons= t char *typename, ObjectClass *klass; Object *obj; ObjectProperty *prop; + ClassProperty *cprop; ObjectPropertyIterator iter; ObjectPropertyInfoList *prop_list =3D NULL; =20 @@ -172,6 +184,18 @@ ObjectPropertyInfoList *qmp_device_list_properties(con= st char *typename, QAPI_LIST_PREPEND(prop_list, info); } =20 + class_property_iter_init(&iter, klass); + while ((cprop =3D class_property_iter_next(&iter))) { + ObjectPropertyInfo *info; + + info =3D g_new0(ObjectPropertyInfo, 1); + info->name =3D g_strdup(cprop->name); + info->type =3D g_strdup(cprop->type); + info->description =3D g_strdup(cprop->description); + + QAPI_LIST_PREPEND(prop_list, info); + } + object_unref(obj); =20 return prop_list; @@ -183,6 +207,7 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const c= har *typename, ObjectClass *klass; Object *obj =3D NULL; ObjectProperty *prop; + ClassProperty *cprop; ObjectPropertyIterator iter; ObjectPropertyInfoList *prop_list =3D NULL; =20 @@ -216,6 +241,18 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const = char *typename, QAPI_LIST_PREPEND(prop_list, info); } =20 + class_property_iter_init(&iter, klass); + while ((cprop =3D class_property_iter_next(&iter))) { + ObjectPropertyInfo *info; + + info =3D g_malloc0(sizeof(*info)); + info->name =3D g_strdup(cprop->name); + info->type =3D g_strdup(cprop->type); + info->description =3D g_strdup(cprop->description); + + QAPI_LIST_PREPEND(prop_list, info); + } + object_unref(obj); =20 return prop_list; --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672769932; cv=none; d=zohomail.com; s=zohoarc; b=ILHQFGp75Ui84hNJak+OQwxXBtS+N3POdJ1BH6FeQpIoopMMCTrmenIQeQMkeRU3o39m96HHpbJvLOCRIMhLEbXi/KWJFHh0IT1YOf39SRWZjgnz595rkVB6duftheKWBctidUDM36q87siLBfilitDfKDzzbj8jMDzhs2XxkkE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672769932; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=HqfB1rYBt/JJ41xGurvUZv7qvN+1zDd4tBuTAwoD6lU=; b=DFmoRBgI9Iv4xNhES3i0eBrW6LW0164VuFkM660G7ZG+OudeRdsjCXYx+LcxwPEfNuQWKR17fxyegY8Ce/ngwQeAppbU4sw/wb1YBB0KE6tSWTUgrMM+d8c3uADt3U4S/NuWh0w4VzCeLo/DElMKxM7KcAHQwhbR1ROY/XU5olw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672769932299211.86676225659085; Tue, 3 Jan 2023 10:18:52 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrX-0008Sl-BO; Tue, 03 Jan 2023 13:18: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 1pClqU-0008G3-Rw for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:22 -0500 Received: from mail-yw1-x1135.google.com ([2607:f8b0:4864:20::1135]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClqT-00058C-7W for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:06 -0500 Received: by mail-yw1-x1135.google.com with SMTP id 00721157ae682-466c5fb1c39so435115537b3.10 for ; Tue, 03 Jan 2023 10:17:04 -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.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:03 -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=HqfB1rYBt/JJ41xGurvUZv7qvN+1zDd4tBuTAwoD6lU=; b=zs4hdB3aSZm8LzCLXbA6Sy8Uf8FVVVBtqTNGp3VVazoS9u0699s3XU0BdCxhOqLwBU yspbF9lpf/HYTnvJ9RBF15TvytUGwCoQmZ7RWz2qMmHEoqA8FrB1jC3YGf6j7S0SfoIg Qoz6e7CeWKZ3b7spH6gl/w9hUvxoKI4Bj9GT2pvVzCQQ11gMFJit/OZiMQkkgKK2NKo0 8NJ5TVI6LwLZuqufIKfESq1GxzYVR8RXJmmvBIlwv43OWYYMUPui+n26rNYbN+db2kKC QYDv42X33J54/EKrF5B7tWfG6I2aL5yN1I+nwQJUkRPzNPJ4kMo9yfnCN2sBgcAKzDcl kn4Q== 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=HqfB1rYBt/JJ41xGurvUZv7qvN+1zDd4tBuTAwoD6lU=; b=0Ndkl0SWkMwoCvCiTz9ZKZO67Nntb0n+GPntqdQ3jePLSJ2f95CkOWcP/2iDvwllH1 t63qG71apgmkrd/3QqXe5pmgimxiFYm7weIh2avzyfVwIqGU0NxBUSJSFjwTVoVIJ1Or Y5b4h5YPE84VdupBdMEL1S71MZU0iOeXxBhoUbDkL2jAx8XSUfYrDtnfxO3J+g2Qg/OL ErJyKYy/oe8TNhq9E9qU0oUF3ckAI1Wm/OvyjT72iBhmmN5BE0TgJz+IPJpIIVxKSpXO mzscScvzAs0QN2Cs4ce//ljsrNV/VDZtnYOotMqZyjZpZxEgJ6PO/aM9y2ihB0y2+GZt sjWQ== X-Gm-Message-State: AFqh2koaZHalrSvZj4Bica9GCEryHmzPusTDZch/SAd4pwb1HWoOfTXz HSDXKsr45Gi+1kl5lKlAiPbBmuCfE0Ri89lQpS4= X-Google-Smtp-Source: AMrXdXvKzVspLZdCJW/OXViT8x/MXmMVcCeq95JHl7YKTcNIUuKp2T9kMvcf502/S9t3H9kjed7p4g== X-Received: by 2002:a81:6ac1:0:b0:4ad:5c08:7e6a with SMTP id f184-20020a816ac1000000b004ad5c087e6amr4071306ywc.39.1672769823506; Tue, 03 Jan 2023 10:17:03 -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 04/40] target/arm: Remove aarch64_cpu_finalizefn Date: Tue, 3 Jan 2023 10:16:10 -0800 Message-Id: <20230103181646.55711-5-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1135; envelope-from=richard.henderson@linaro.org; helo=mail-yw1-x1135.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672769934507100007 Content-Type: text/plain; charset="utf-8" If the instance_finalize hook is NULL, the hook is not called. There is no need to install an empty function. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/cpu64.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 2cf2ca4ce5..611b233d23 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -1351,10 +1351,6 @@ static void aarch64_cpu_set_aarch64(Object *obj, boo= l value, Error **errp) } } =20 -static void aarch64_cpu_finalizefn(Object *obj) -{ -} - static gchar *aarch64_gdb_arch_name(CPUState *cs) { return g_strdup("aarch64"); @@ -1412,7 +1408,6 @@ static const TypeInfo aarch64_cpu_type_info =3D { .name =3D TYPE_AARCH64_CPU, .parent =3D TYPE_ARM_CPU, .instance_size =3D sizeof(ARMCPU), - .instance_finalize =3D aarch64_cpu_finalizefn, .abstract =3D true, .class_size =3D sizeof(AArch64CPUClass), .class_init =3D aarch64_cpu_class_init, --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672769922; cv=none; d=zohomail.com; s=zohoarc; b=dAyHKTWG2+LFiXXZ2W+oG80pp79j9xxvobsNTystKyhnZORuNkiI5DKiytJK/z6g3xBbNjTfRfjLVOtxJ9VyknRn11/zCg/G1gIXldcK9YL7YbtlElNa6qluCzcod+Wfxf+Odzzl29WT66qEEvLE8Qg09+Fp95xXOI5LC7CpavQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672769922; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=xWi29oKGa+vNl3/kuxAMom41NeEPlRY6brtaMJqGau4=; b=DCL/HaVT7sLP9etihyr5jW/SWD/yv87sog6+pmG4kbOpzMpYSA/hUZEEnrODHFKmjYgaPxHQCsgr2ZLHYh9QI7ovMgJyHeX/GcyX2kfeH8QSzLKFXVp1kgnGQkSwrPLDiPCFgb6boTUULh8Zhj4RCAEOP/UYC0h5GrccA6aDE/Q= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672769922422587.5244944825888; Tue, 3 Jan 2023 10:18:42 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrJ-0008OB-LG; Tue, 03 Jan 2023 13:17:57 -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 1pClqW-0008G6-UU for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:20 -0500 Received: from mail-yw1-x1136.google.com ([2607:f8b0:4864:20::1136]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClqV-00058X-F5 for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:08 -0500 Received: by mail-yw1-x1136.google.com with SMTP id 00721157ae682-47fc4e98550so305385157b3.13 for ; Tue, 03 Jan 2023 10:17:06 -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.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:05 -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=xWi29oKGa+vNl3/kuxAMom41NeEPlRY6brtaMJqGau4=; b=szhoI5zwtteKos9lUVeocuGnQAcdqo7k4yGb9qE/WsNE/JExEf2qrecxspkRSlQyuN QeYXjGNS4BqDVfPLCav6j/4h0K8UAsbJ74+V1HJxL0Vgg32DUOl9NrAdg4+lQvo9vrur /CKrPOyJgymNphAysSjDh5mmxf9oOdY2BExKccyLYRM8YncQNCQz0FqYDYmgX3H1RO+n uVH1Bq9d8wQSnWrPa3lHFDLCxBZK5x9mkwdVtPz27q9bdMNZh7l5/CcCu3cRv9iGAQug PITIYjm1akfMrNhoStub11QhqK+CtFyz7NTasnGiW5Gr/VXH0v9mC46ku0iwIg284q/N sTCw== 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=xWi29oKGa+vNl3/kuxAMom41NeEPlRY6brtaMJqGau4=; b=mdZ0PY2/u1pu5+02T4DE+XzG3DRH5964Nx5CjLkOPAcxqkRLKByEM9+qxbxy27WDZG ppjBTPE5+aIJWGWiqDrtuzLHcYY8UOuY9DWq+4Ze7sahO+pKJGNkjjMD8Ow7nWWQfOCQ +h0GdhSzHzjjXIX5QgWsI7J+lKl/TmTpq/oWQMiAhSHX2cwpV0wLnJS056Z11Znt9cdb GAScXDCtxWPA0hPUbCBMTFM1HwxrcEhBUcl8/BEGNhkVsjYcglh+Q0eV1aNJBT8Dvckh oXxyFMIH5Vf2sj8y/+BPliWvGHFTHEjyiVTobI90BiWyTYiv58rEUeySlNYHc9q2anKR tqXQ== X-Gm-Message-State: AFqh2kpNwH0L3d6eroHvkfNkakLsiIe2ydAJhN/ovRrguwmyE8MQ5Lec thhGtF7zQS2rW4OPrT0EQFPol0BMM2b+FRk2sco= X-Google-Smtp-Source: AMrXdXvrnU8AnAyG6IcZWpi0t28dyQ3I71UU65B5wVigPYTUEChuScPFe/ABaZ53CLPJydF1OLacng== X-Received: by 2002:a81:6c56:0:b0:3d1:1a2f:2706 with SMTP id h83-20020a816c56000000b003d11a2f2706mr43478165ywc.50.1672769826146; Tue, 03 Jan 2023 10:17:06 -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 05/40] target/arm: Create arm_cpu_register_parent Date: Tue, 3 Jan 2023 10:16:11 -0800 Message-Id: <20230103181646.55711-6-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1136; envelope-from=richard.henderson@linaro.org; helo=mail-yw1-x1136.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672769924495100003 Content-Type: text/plain; charset="utf-8" Create an arm cpu class with a specific abstract parent class. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/cpu-qom.h | 7 ++++++- target/arm/cpu.c | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h index 514c22ced9..95f7805076 100644 --- a/target/arm/cpu-qom.h +++ b/target/arm/cpu-qom.h @@ -37,9 +37,14 @@ typedef struct ARMCPUInfo { void (*class_init)(ObjectClass *oc, void *data); } ARMCPUInfo; =20 -void arm_cpu_register(const ARMCPUInfo *info); +void arm_cpu_register_parent(const ARMCPUInfo *info, const char *parent); void aarch64_cpu_register(const ARMCPUInfo *info); =20 +static inline void arm_cpu_register(const ARMCPUInfo *info) +{ + arm_cpu_register_parent(info, TYPE_ARM_CPU); +} + /** * ARMCPUClass: * @parent_realize: The parent class' realize handler. diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 2fa022f62b..c97461e164 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2260,10 +2260,10 @@ static void cpu_register_class_init(ObjectClass *oc= , void *data) acc->info =3D data; } =20 -void arm_cpu_register(const ARMCPUInfo *info) +void arm_cpu_register_parent(const ARMCPUInfo *info, const char *parent) { TypeInfo type_info =3D { - .parent =3D TYPE_ARM_CPU, + .parent =3D parent, .instance_size =3D sizeof(ARMCPU), .instance_align =3D __alignof__(ARMCPU), .instance_init =3D arm_cpu_instance_init, --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672769948; cv=none; d=zohomail.com; s=zohoarc; b=fR+ZOUebbqXrtZJmXw9CZ6WeX+uWk+7/ZAbFzx09brve1EotHHuTeNdlB3h52RpiE5xYvIugGE7jKwrNRCpkPjMbN2McQZ1l16/X9oAzp7D4nZ89WP5IC7KAvDLJ3imD/Rv5LkEZKai8h6d/GlImZoZiC9BgAfntBqtTzEhkM80= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672769948; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/hcmB2LT/3scWI6D2yw07Zg5GL1YtQ6uMDjg/q/TVb4=; b=Jrj4sdDApPJ8fgLJjpd03/0Pnpb8kuZwvflRSWzKPlKzPk0wVSWZS+c/X7po/5QJycDtPQf5fE8kKmf7aq7QLkhySuur5LZgaFiFHICC8PJ8czMgQXdPofwQGz+T5oh8qy4YtMJ+SX8cTml5LB/B6YlS1MXUWkH//0cJWnqX2j4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672769948186882.7046035176368; Tue, 3 Jan 2023 10:19:08 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrL-0008OW-8o; Tue, 03 Jan 2023 13:18:08 -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 1pClqb-0008Ho-Oq for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:22 -0500 Received: from mail-yb1-xb35.google.com ([2607:f8b0:4864:20::b35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClqZ-0005AU-2l for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:12 -0500 Received: by mail-yb1-xb35.google.com with SMTP id e141so34042620ybh.3 for ; Tue, 03 Jan 2023 10:17:09 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:08 -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=/hcmB2LT/3scWI6D2yw07Zg5GL1YtQ6uMDjg/q/TVb4=; b=XUGpTbJPJfF5KQ6uD9SvIIRrc+MftcDkf6HVV6Om89nUGHahTin7rZMf3NY7np9FK6 4ZmZQVOROuYU90w0TO83nC37AIkz1OTXic9ARI5OIe2H2AGy2HcjbxC01rk3R/QicGVO 7xm1Yvp+LUgl8DYlBaKKN/xdb43ScfId4UnMOoI409mowbzTePyROpFnekEgWupvUXR7 j19Wa+mRUgjH91I6ZsTwsDajAjEhs5X9dE1LDBpGNr0UItprgDAfCvcDZXV114Txkgc6 4nWmnt7ShVZCvHiiKS+AlaCtMp40pJYpQs0NkjFUrdW5uWSTwzCo3r7uG6lBfj1myln5 l8kw== 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=/hcmB2LT/3scWI6D2yw07Zg5GL1YtQ6uMDjg/q/TVb4=; b=4Mzi1gE4f7LsLbU8YxWTIELf8CEZa43JPtKLsKpXtfkHNvibfhXxvyGPlEZWa+VkfL bE0GsqurotKMQ6xk5zgPfMN2GVrewbluX8ju356HghPyxTmvkN4yaher1O37Lne0mte5 rkk8/mgA3tx9FHDer9F9LEC3c206byyJBnJiBAxuOib178jzsPyc3LTybAOdI1YCPsk/ vFmuqopDZ9RU2x1OlkZGDpm0pg1wuQJi0twdGi3NrE6ZDqfC3wEReOsjJPKxUdLV4bDi 7eqnAAb/kGExzvpT67MWpOrl5JE+fuqRLOabPSt+OSu9iJjke/ORtMMy+8UWEtEiU+KZ bAvw== X-Gm-Message-State: AFqh2kq0oE0fmoQZmmqsHmtNbofKqtCtIoPO8EB+XjyXcbNRYyOiKgSn Dv62lcxamfFRL8Voxqs//C+zBfM0wuuI5ISiLoo= X-Google-Smtp-Source: AMrXdXvw3kLa/JIeLtsOsEF8VrJIBEo4WLAfSwm6JiGFI+XbHVrJC8zmN84frIEam0Jd4K1iWUDWcg== X-Received: by 2002:a25:8904:0:b0:6f5:758f:43b with SMTP id e4-20020a258904000000b006f5758f043bmr42221079ybl.41.1672769828790; Tue, 03 Jan 2023 10:17:08 -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 06/40] target/arm: Remove AArch64CPUClass Date: Tue, 3 Jan 2023 10:16:12 -0800 Message-Id: <20230103181646.55711-7-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::b35; envelope-from=richard.henderson@linaro.org; helo=mail-yb1-xb35.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672769948623100001 Content-Type: text/plain; charset="utf-8" The class structure is a plain wrapper around ARMCPUClass. We really only need the QOM class, TYPE_AARCH64_CPU. The instance init and fallback class init functions are identical to the same ones over in cpu.c. Make arm_cpu_post_init static. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/cpu-qom.h | 19 ++++++------------- target/arm/cpu.h | 2 -- target/arm/cpu.c | 2 +- target/arm/cpu64.c | 33 +-------------------------------- 4 files changed, 8 insertions(+), 48 deletions(-) diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h index 95f7805076..184b3e3726 100644 --- a/target/arm/cpu-qom.h +++ b/target/arm/cpu-qom.h @@ -26,6 +26,7 @@ struct arm_boot_info; =20 #define TYPE_ARM_CPU "arm-cpu" +#define TYPE_AARCH64_CPU "aarch64-cpu" =20 OBJECT_DECLARE_CPU_TYPE(ARMCPU, ARMCPUClass, ARM_CPU) =20 @@ -38,13 +39,17 @@ typedef struct ARMCPUInfo { } ARMCPUInfo; =20 void arm_cpu_register_parent(const ARMCPUInfo *info, const char *parent); -void aarch64_cpu_register(const ARMCPUInfo *info); =20 static inline void arm_cpu_register(const ARMCPUInfo *info) { arm_cpu_register_parent(info, TYPE_ARM_CPU); } =20 +static inline void aarch64_cpu_register(const ARMCPUInfo *info) +{ + arm_cpu_register_parent(info, TYPE_AARCH64_CPU); +} + /** * ARMCPUClass: * @parent_realize: The parent class' realize handler. @@ -62,18 +67,6 @@ struct ARMCPUClass { ResettablePhases parent_phases; }; =20 - -#define TYPE_AARCH64_CPU "aarch64-cpu" -typedef struct AArch64CPUClass AArch64CPUClass; -DECLARE_CLASS_CHECKERS(AArch64CPUClass, AARCH64_CPU, - TYPE_AARCH64_CPU) - -struct AArch64CPUClass { - /*< private >*/ - ARMCPUClass parent_class; - /*< public >*/ -}; - void register_cp_regs_for_features(ARMCPU *cpu); void init_cpreg_list(ARMCPU *cpu); =20 diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 2b4bd20f9d..3ac650092f 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1076,8 +1076,6 @@ struct ArchCPU { =20 unsigned int gt_cntfrq_period_ns(ARMCPU *cpu); =20 -void arm_cpu_post_init(Object *obj); - uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz); =20 #ifndef CONFIG_USER_ONLY diff --git a/target/arm/cpu.c b/target/arm/cpu.c index c97461e164..a2f59ac378 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1324,7 +1324,7 @@ unsigned int gt_cntfrq_period_ns(ARMCPU *cpu) NANOSECONDS_PER_SECOND / cpu->gt_cntfrq_hz : 1; } =20 -void arm_cpu_post_init(Object *obj) +static void arm_cpu_post_init(Object *obj) { ARMCPU *cpu =3D ARM_CPU(obj); =20 diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 611b233d23..1d3aff868d 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -1373,43 +1373,12 @@ static void aarch64_cpu_class_init(ObjectClass *oc,= void *data) "execution state "); } =20 -static void aarch64_cpu_instance_init(Object *obj) -{ - ARMCPUClass *acc =3D ARM_CPU_GET_CLASS(obj); - - acc->info->initfn(obj); - arm_cpu_post_init(obj); -} - -static void cpu_register_class_init(ObjectClass *oc, void *data) -{ - ARMCPUClass *acc =3D ARM_CPU_CLASS(oc); - - acc->info =3D data; -} - -void aarch64_cpu_register(const ARMCPUInfo *info) -{ - TypeInfo type_info =3D { - .parent =3D TYPE_AARCH64_CPU, - .instance_size =3D sizeof(ARMCPU), - .instance_init =3D aarch64_cpu_instance_init, - .class_size =3D sizeof(ARMCPUClass), - .class_init =3D info->class_init ?: cpu_register_class_init, - .class_data =3D (void *)info, - }; - - type_info.name =3D g_strdup_printf("%s-" TYPE_ARM_CPU, info->name); - type_register(&type_info); - g_free((void *)type_info.name); -} - static const TypeInfo aarch64_cpu_type_info =3D { .name =3D TYPE_AARCH64_CPU, .parent =3D TYPE_ARM_CPU, .instance_size =3D sizeof(ARMCPU), .abstract =3D true, - .class_size =3D sizeof(AArch64CPUClass), + .class_size =3D sizeof(ARMCPUClass), .class_init =3D aarch64_cpu_class_init, }; =20 --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770135; cv=none; d=zohomail.com; s=zohoarc; b=M72Ge4drAStTPgAS3ioZfe6G/zUqrjoKxLDAWyjfq9+MKKKtZiGv/AqxJSS0JYOVH5FUsxQs2e2WsS8/3fD5lpFNr5qAEi0mMdZu5y1ZwFdsuQ/hp6W0CBR0h5ItsTvbHYFIKCr54eLyLqsjriutOw3pOuLXME49hb9Nxq+Z+r0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770135; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ox6lsVTv8H7bR8+2oGArM6AIjDyJ3hXTv/IB/m/B3mo=; b=U6hC4xXOPDmGGLbLVdCb/k7ohp4XSeSlwSDsiH7RJ455foDCqNt8hVwpy23eh1Rc8EovURVlj3NP11+Wk6iaxsHoazXISSoxLkZIFVZ86+iJbI3tMvyazD8Md6I5vXFy3o+yTtBIDxA91A86ezKy1PnR/soGk1ZKAKtvTB3h1Fw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770135354859.4656709108581; Tue, 3 Jan 2023 10:22:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrd-0000FW-Qo; Tue, 03 Jan 2023 13:18:17 -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 1pClqd-0008Hr-5h for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:22 -0500 Received: from mail-vs1-xe2f.google.com ([2607:f8b0:4864:20::e2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClqa-0005C0-Ix for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:14 -0500 Received: by mail-vs1-xe2f.google.com with SMTP id 3so32565189vsq.7 for ; Tue, 03 Jan 2023 10:17:12 -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.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:11 -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=ox6lsVTv8H7bR8+2oGArM6AIjDyJ3hXTv/IB/m/B3mo=; b=O4U5yWLi2TkgpJ2sRi0svKPJKcgBeALOPFCdTuHX9Wr8Ol4asCvQR5rdb7h1Lp4s5W X9cKJ3NHWUq/1kPDy3xSi7sgvWFO2RBwdJzv5oBdJFzREb1FKLEnMdak9L7vedilUtUr kOCR5y0USU9JDgWcZ4Pkaao4WanGRWhC4JnbdZBixfyks7NBgxmdvUVYXRjrcLYIBRdz nihVQt1NLpdLs2WxANVkDPaed3/3Im8kGks9BJzP5ANzoh1cozvfemFHCkotFIbTaU5a Zn/goluhN2HKVabspJGnQg0mx/q+d6j/4OF6RnK6EXkk8qxsy7H7Yzq8xVP9uxWTFEfW /bJQ== 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=ox6lsVTv8H7bR8+2oGArM6AIjDyJ3hXTv/IB/m/B3mo=; b=yeRNOjWHl6nfZHA3r3dUaQbbC+Cagg916fyuEJhKaGz5U4w+upJlKBodiT8sjCDnEU WIY8EdgAGJ9zdEQL2C/TjbEjDU0Ytd16uNm2ZcEEF1IHGdsKu1QU5GAVZrBp0uH2UKmm wZw0kHufPuebQ24FqyxVVs6XGBgsfc3x1axyZqdIbk/yMQubCLLTJty7xTC8Cxu3ywAD WmtlMS5inJFWXwQqhL42pX7JTp7PjNDQb3D2P+oMJ30WSVKNoe/ezeJJOIZ3VjHhx0V6 eLFOt6BaymLqpfLdvqM9zaTA9Jt+WjQx1U+az6sGQFIGTmoNeB2H4THtBUxPeDA9cwhC hosw== X-Gm-Message-State: AFqh2kqJYmbo9gQn/D/Ivcl7eyO2PyJablOjzNczolkmFzO7JVmgyR01 JI0SPvn56gE99Ubfrv5rOY2wJWXbN3vgLQ7Pmuk= X-Google-Smtp-Source: AMrXdXve3CdxD1Q25g6/PqkLjVah2/PH5BAF02pCzhTd9RW9zJL3+L/XVsvgHPKJuW79jvOAYqBBZQ== X-Received: by 2002:a67:e05a:0:b0:3ce:9149:5360 with SMTP id n26-20020a67e05a000000b003ce91495360mr3321799vsl.7.1672769831526; Tue, 03 Jan 2023 10:17:11 -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 07/40] target/arm: Create TYPE_ARM_V7M_CPU Date: Tue, 3 Jan 2023 10:16:13 -0800 Message-Id: <20230103181646.55711-8-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::e2f; envelope-from=richard.henderson@linaro.org; helo=mail-vs1-xe2f.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770137445100003 Content-Type: text/plain; charset="utf-8" Create a new intermediate abstract class for v7m, like we do for aarch64. The initialization of ARMCPUClass.info follows the concrete class, so remove that init from arm_v7m_class_init. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/cpu-qom.h | 6 ++++++ target/arm/cpu_tcg.c | 36 ++++++++++++++++++++++-------------- 2 files changed, 28 insertions(+), 14 deletions(-) diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h index 184b3e3726..ae31289582 100644 --- a/target/arm/cpu-qom.h +++ b/target/arm/cpu-qom.h @@ -26,6 +26,7 @@ struct arm_boot_info; =20 #define TYPE_ARM_CPU "arm-cpu" +#define TYPE_ARM_V7M_CPU "arm-v7m-cpu" #define TYPE_AARCH64_CPU "aarch64-cpu" =20 OBJECT_DECLARE_CPU_TYPE(ARMCPU, ARMCPUClass, ARM_CPU) @@ -45,6 +46,11 @@ static inline void arm_cpu_register(const ARMCPUInfo *in= fo) arm_cpu_register_parent(info, TYPE_ARM_CPU); } =20 +static inline void arm_v7m_cpu_register(const ARMCPUInfo *info) +{ + arm_cpu_register_parent(info, TYPE_ARM_V7M_CPU); +} + static inline void aarch64_cpu_register(const ARMCPUInfo *info) { arm_cpu_register_parent(info, TYPE_AARCH64_CPU); diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c index 568cbcfc52..d566a815d3 100644 --- a/target/arm/cpu_tcg.c +++ b/target/arm/cpu_tcg.c @@ -1056,10 +1056,8 @@ static const struct TCGCPUOps arm_v7m_tcg_ops =3D { =20 static void arm_v7m_class_init(ObjectClass *oc, void *data) { - ARMCPUClass *acc =3D ARM_CPU_CLASS(oc); CPUClass *cc =3D CPU_CLASS(oc); =20 - acc->info =3D data; #ifdef CONFIG_TCG cc->tcg_ops =3D &arm_v7m_tcg_ops; #endif /* CONFIG_TCG */ @@ -1149,18 +1147,6 @@ static const ARMCPUInfo arm_tcg_cpus[] =3D { { .name =3D "cortex-a8", .initfn =3D cortex_a8_initfn }, { .name =3D "cortex-a9", .initfn =3D cortex_a9_initfn }, { .name =3D "cortex-a15", .initfn =3D cortex_a15_initfn }, - { .name =3D "cortex-m0", .initfn =3D cortex_m0_initfn, - .class_init =3D arm_v7m_class_init }, - { .name =3D "cortex-m3", .initfn =3D cortex_m3_initfn, - .class_init =3D arm_v7m_class_init }, - { .name =3D "cortex-m4", .initfn =3D cortex_m4_initfn, - .class_init =3D arm_v7m_class_init }, - { .name =3D "cortex-m7", .initfn =3D cortex_m7_initfn, - .class_init =3D arm_v7m_class_init }, - { .name =3D "cortex-m33", .initfn =3D cortex_m33_initfn, - .class_init =3D arm_v7m_class_init }, - { .name =3D "cortex-m55", .initfn =3D cortex_m55_initfn, - .class_init =3D arm_v7m_class_init }, { .name =3D "cortex-r5", .initfn =3D cortex_r5_initfn }, { .name =3D "cortex-r5f", .initfn =3D cortex_r5f_initfn }, { .name =3D "ti925t", .initfn =3D ti925t_initfn }, @@ -1187,6 +1173,24 @@ static const ARMCPUInfo arm_tcg_cpus[] =3D { #endif }; =20 +static const ARMCPUInfo arm_v7m_tcg_cpus[] =3D { + { .name =3D "cortex-m0", .initfn =3D cortex_m0_initfn }, + { .name =3D "cortex-m3", .initfn =3D cortex_m3_initfn }, + { .name =3D "cortex-m4", .initfn =3D cortex_m4_initfn }, + { .name =3D "cortex-m7", .initfn =3D cortex_m7_initfn }, + { .name =3D "cortex-m33", .initfn =3D cortex_m33_initfn }, + { .name =3D "cortex-m55", .initfn =3D cortex_m55_initfn }, +}; + +static const TypeInfo arm_v7m_cpu_type_info =3D { + .name =3D TYPE_ARM_V7M_CPU, + .parent =3D TYPE_ARM_CPU, + .instance_size =3D sizeof(ARMCPU), + .abstract =3D true, + .class_size =3D sizeof(ARMCPUClass), + .class_init =3D arm_v7m_class_init, +}; + static const TypeInfo idau_interface_type_info =3D { .name =3D TYPE_IDAU_INTERFACE, .parent =3D TYPE_INTERFACE, @@ -1197,10 +1201,14 @@ static void arm_tcg_cpu_register_types(void) { size_t i; =20 + type_register_static(&arm_v7m_cpu_type_info); type_register_static(&idau_interface_type_info); for (i =3D 0; i < ARRAY_SIZE(arm_tcg_cpus); ++i) { arm_cpu_register(&arm_tcg_cpus[i]); } + for (i =3D 0; i < ARRAY_SIZE(arm_v7m_tcg_cpus); ++i) { + arm_v7m_cpu_register(&arm_v7m_tcg_cpus[i]); + } } =20 type_init(arm_tcg_cpu_register_types) --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672769902; cv=none; d=zohomail.com; s=zohoarc; b=G17Nqsh0pjvEowp395eoSTa94WRxhkqWfp+bwYiEA2ohucxc3xmFGGK4q3qbQ/mk7Ktvm12UWnJrYbluD3ZkC7RGlw5U6DW8kOdxWp9SzMVYYyt9eYpRIgsTEuoFSlBsywG+ZpNLr+YrGBzGCv9M+BT652EomjlrVKHYLlyqORE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672769902; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XAGObJvGqrVWdz2gSKRqPWH5ISliRfssMEo9w+SvRe8=; b=BQUdYm8HIm6WB04tpXf4d7mamwXHpQYIBX2D1v3hQRFcn3g9+6dZKtf1OGfe1oX61nqcFO3bg5+bTFH9JriKhPguF8rNBM5rCImlUmCr20O3O3CcbdciUCsMXRL67ZQOmzaWsk7ctXTTCB5bg2bpNS3ts+o+rb4kbHH9nlw8xgA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672769902357446.9317049567335; Tue, 3 Jan 2023 10:18:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrX-0008Sn-By; Tue, 03 Jan 2023 13:18: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 1pClqg-0008I4-3r for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:22 -0500 Received: from mail-vs1-xe31.google.com ([2607:f8b0:4864:20::e31]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClqd-0005CK-OG for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:17 -0500 Received: by mail-vs1-xe31.google.com with SMTP id p30so26963198vsr.1 for ; Tue, 03 Jan 2023 10:17:15 -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.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:14 -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=XAGObJvGqrVWdz2gSKRqPWH5ISliRfssMEo9w+SvRe8=; b=LSS15VX8SvVQ+6ffZOzSViYP69YP+saEqdoygB8fwAc6jswtQeJSJ6qJloX7DYA2Zy YblpNcvR4aUxzxgtCDs8LI9+U8K9ZjZClFS/sgHjptiN6CqhLHOs4kj1NI4wJhcXfE7Y B1+3PVaB55jCD+rNEF4sIx+7poEl+7VxbvdV4tN56VgfqVzpz01eerbTUtiqEN5PvYmO WQ8joL72c7SROTgmin2IJ/Km7JNXEuyEDKjmRXecMERKhWqYNfb2NtVUs426OM8sg8yB AGOzJQZZr+BJr/x2u2zdhf3lN0ZSIVf7IysOdcn1nI3htifxCvU9lqLYGIgrZpTMPH1v oCCA== 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=XAGObJvGqrVWdz2gSKRqPWH5ISliRfssMEo9w+SvRe8=; b=I22wefYmUr/93AiRNf5Hh/aN5mWAvPXb6/cTVON09HJvCWXWlyOxvRvy+ghmWdId1P mzkvj4wnOQLE4swRD9GJLAtREQWdxVdVw/MKW/EkphOqrPNjufesG19k41yN4Y+0Njeh Qd/FLfb89GHOJSbsoeEI4nE9+DmHLw3XedDsMHzUmrU+LxQ7Ixp4Dg0TtjI65lNJZqzF YLAp3N479xnicFtkGcSrCYw52uhbd0AgPUulY5LD3RzeMn9/937/zlvlMh+u+WHrrqNe DrVQu9d0vdrw92STHR6rbjoK6dvNf2WDyff6kr+vdXfE3PDSYxH18Nn/peUC4TqdyUY4 iEtQ== X-Gm-Message-State: AFqh2konLigUG7Crqs/cCcq4R6ROP6tv7KmvwaO0Pj6CAUYr4bZ0+WYR 5FdHyULaAxttJcj2t8nyV5f/NN76Yx4LkC+3CGA= X-Google-Smtp-Source: AMrXdXtCzC30j7c3N7zT23dqxspa+91sGDOFy9uTUEgzR/z5C7IXJNXIDqe55bHgot7piHgdn8BG1A== X-Received: by 2002:a05:6102:a4a:b0:3cb:93d:406f with SMTP id i10-20020a0561020a4a00b003cb093d406fmr12585208vss.32.1672769834757; Tue, 03 Jan 2023 10:17:14 -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 08/40] target/arm: Pass ARMCPUClass to ARMCPUInfo.class_init Date: Tue, 3 Jan 2023 10:16:14 -0800 Message-Id: <20230103181646.55711-9-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::e31; envelope-from=richard.henderson@linaro.org; helo=mail-vs1-xe31.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672769904570100003 Content-Type: text/plain; charset="utf-8" Streamline new instances of this hook, so that we always go through arm_cpu_leaf_class_init first, performing common tasks, and have resolved the ARMCPUClass. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/cpu-qom.h | 2 +- target/arm/cpu.c | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h index ae31289582..057978b9db 100644 --- a/target/arm/cpu-qom.h +++ b/target/arm/cpu-qom.h @@ -36,7 +36,7 @@ OBJECT_DECLARE_CPU_TYPE(ARMCPU, ARMCPUClass, ARM_CPU) typedef struct ARMCPUInfo { const char *name; void (*initfn)(Object *obj); - void (*class_init)(ObjectClass *oc, void *data); + void (*class_init)(ARMCPUClass *acc); } ARMCPUInfo; =20 void arm_cpu_register_parent(const ARMCPUInfo *info, const char *parent); diff --git a/target/arm/cpu.c b/target/arm/cpu.c index a2f59ac378..b16d9bbe47 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2253,11 +2253,15 @@ static void arm_cpu_instance_init(Object *obj) arm_cpu_post_init(obj); } =20 -static void cpu_register_class_init(ObjectClass *oc, void *data) +static void arm_cpu_leaf_class_init(ObjectClass *oc, void *data) { ARMCPUClass *acc =3D ARM_CPU_CLASS(oc); + const ARMCPUInfo *info =3D data; =20 - acc->info =3D data; + acc->info =3D info; + if (info->class_init) { + info->class_init(acc); + } } =20 void arm_cpu_register_parent(const ARMCPUInfo *info, const char *parent) @@ -2268,7 +2272,7 @@ void arm_cpu_register_parent(const ARMCPUInfo *info, = const char *parent) .instance_align =3D __alignof__(ARMCPU), .instance_init =3D arm_cpu_instance_init, .class_size =3D sizeof(ARMCPUClass), - .class_init =3D info->class_init ?: cpu_register_class_init, + .class_init =3D arm_cpu_leaf_class_init, .class_data =3D (void *)info, }; =20 --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770537; cv=none; d=zohomail.com; s=zohoarc; b=WLjw4/iU4cvnsukeD3Id1Id0ocvdzb/UjVxARMgd4XMau1RTj4ytqWQK/ir6CKzDcJnwqpeRFQvCHANFNdd5C6op3Nr/4/ZOlXdAiQ9raCu5c2QHrkxtCRw9h02qe8qk0uDtXdOw+A3fbRqhJbP9NsSrbkmkk456yaldFDmSC/k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770537; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Q1oCoDY8fhpidPn09tNWnDVDs+nP6yjSMDN5nvvhyRs=; b=kcnrP2qHeCWOID63Pcq7auyJgKwrUiZpQxFqKpalV4hVke5GRnpCmVtz1QCKskAFbUVYxPcGz1/+FJZNyOZG1RDWZgKHr3RRf+IsCW6cCdoGFBd6IXHsAdiCupZQ9V4spIIFGP//yF3OYFlq4ZeDVR7wSaf5jCNvjdIoB/GtRwQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770537244903.2221926779212; Tue, 3 Jan 2023 10:28:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrb-00009X-Go; Tue, 03 Jan 2023 13:18:15 -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 1pClqj-0008IA-08 for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:24 -0500 Received: from mail-vk1-xa2f.google.com ([2607:f8b0:4864:20::a2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClqg-0005Ce-L8 for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:19 -0500 Received: by mail-vk1-xa2f.google.com with SMTP id g65so12258120vkh.8 for ; Tue, 03 Jan 2023 10:17:18 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:17 -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=Q1oCoDY8fhpidPn09tNWnDVDs+nP6yjSMDN5nvvhyRs=; b=SkvaT8l++k2rTo+ucw3PdOj9N7qGbIGlgBdR8KQ1QRIzlXmYV8+1H4hdSMNWmq5SUc ILlEMJ1o8cSB/n9EaYHwU/dlajDWTnJoYTOyWd4/Dj/0xcjmnXXg9trHS8/4BoduShA3 m5PWANUFjb6E7Ru80MjWTIN0wvPuauRchE6GIERP5SE4oJGKMTFllutkGH5yd+ddjPxn 0V80OgwPhU92v6k7lY+fuHd8NhVit9NKzqYPuAC8PwnPG8DO22PSpPkiXJJLL5AQMyDW FsKpwciT57zio4bVvPXQtYXrjI7KY62ioJSejGl1mWaEY7a+axdIFJwFQZkugoy9JzAG wkHg== 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=Q1oCoDY8fhpidPn09tNWnDVDs+nP6yjSMDN5nvvhyRs=; b=s+CWTDox+ZKJySLO5NwsSLEYn9Q9TK7ME6dg6Vs4uV47pJ33XYv3VOdzDnD/EnqKB4 r568jJyTYF4ECdjTqPRmycQGInZmNmj84HQNLd6Z6krSLcqBuZflLfRbLSdxRpoPO8h+ z6TTw4i4dARLQH/Rh8GQGvTl647htzuBpd4cfw3r/bfF4CxHcqCnV3seEpDhV4EbQGnf 58gdCwqBXBeBg+C6XaeTfF4QtQe3raW8xxSw8HrT7qGnNNq8zY3iXbq+tC/+68ps3Axa r0/Um32MVJhDc3RRXCkjDplh0k75NhG0/PCFX5dN3/tF5BakoANhV3Vu0XuzN1RBacPD e+Ig== X-Gm-Message-State: AFqh2kq/8dZAbHQFlZe4qPwMHfA1AY6JPZ58TldJ8Ng5op9PCcWPeICU R/mn2Sqpe+OmOBIPfc6jKsXPYt/xwOVEq8/4yyU= X-Google-Smtp-Source: AMrXdXvZrpGXt5ZW/6W8Uxt7dQHB1FOvxKAJsbuRy4riqN/FbQCPB58gmy2rI97YnYkk7F2qem2qDw== X-Received: by 2002:a1f:6012:0:b0:3d5:a227:6e46 with SMTP id u18-20020a1f6012000000b003d5a2276e46mr6572135vkb.5.1672769837686; Tue, 03 Jan 2023 10:17:17 -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 09/40] target/arm: Utilize arm-cpu instance_post_init hook Date: Tue, 3 Jan 2023 10:16:15 -0800 Message-Id: <20230103181646.55711-10-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::a2f; envelope-from=richard.henderson@linaro.org; helo=mail-vk1-xa2f.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770538380100001 Content-Type: text/plain; charset="utf-8" Rather than call arm_cpu_post_init ourselves from the object instance_init, let QOM handle this. Signed-off-by: Richard Henderson --- target/arm/cpu.c | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index b16d9bbe47..a6c6916f36 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2245,14 +2245,6 @@ static void arm_cpu_class_init(ObjectClass *oc, void= *data) #endif /* CONFIG_TCG */ } =20 -static void arm_cpu_instance_init(Object *obj) -{ - ARMCPUClass *acc =3D ARM_CPU_GET_CLASS(obj); - - acc->info->initfn(obj); - arm_cpu_post_init(obj); -} - static void arm_cpu_leaf_class_init(ObjectClass *oc, void *data) { ARMCPUClass *acc =3D ARM_CPU_CLASS(oc); @@ -2270,7 +2262,7 @@ void arm_cpu_register_parent(const ARMCPUInfo *info, = const char *parent) .parent =3D parent, .instance_size =3D sizeof(ARMCPU), .instance_align =3D __alignof__(ARMCPU), - .instance_init =3D arm_cpu_instance_init, + .instance_init =3D info->initfn, .class_size =3D sizeof(ARMCPUClass), .class_init =3D arm_cpu_leaf_class_init, .class_data =3D (void *)info, @@ -2287,6 +2279,7 @@ static const TypeInfo arm_cpu_type_info =3D { .instance_size =3D sizeof(ARMCPU), .instance_align =3D __alignof__(ARMCPU), .instance_init =3D arm_cpu_initfn, + .instance_post_init =3D arm_cpu_post_init, .instance_finalize =3D arm_cpu_finalizefn, .abstract =3D true, .class_size =3D sizeof(ARMCPUClass), --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770299; cv=none; d=zohomail.com; s=zohoarc; b=MzHPR6iRsPD9c0AnyNms0efVHtNOeLBF0xcLdpfaLquZ+qrNdsiOmyFiol9T7/U76lG6tZWgyC7XjeTTl/fzbIl5RDznN8B80SlWmIjJSqdupku9Ej/yUK0uv+cr07NJZt9lvCe+hursBbpYXNnAdHeOSHkTw57okSL10lo+O98= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770299; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ZkEGcogj27YdFJQTywgiITgHI/jXlYMGF8YkSZKNLjc=; b=jf3Oz9fEN+L+3t9pSc519U/Kw5eOmRarsf//6eOPqoF52tgNOoXfu361WNc2+qAspBADIUWlY5xZ9pihIq1qTEE3/ZU2y1GAZLWKoCFudeQjQkXBAbkAeWK+9lZwJoVad/TOVpbYBXx1F4L6WOgjFB8JaOF455C4YDA5gMNNo60= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16727702996591020.5686174001107; Tue, 3 Jan 2023 10:24:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClre-0000HP-Qw; Tue, 03 Jan 2023 13:18:18 -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 1pClqm-0008IM-Os for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:40 -0500 Received: from mail-vs1-xe2f.google.com ([2607:f8b0:4864:20::e2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClqk-0005C0-LR for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:23 -0500 Received: by mail-vs1-xe2f.google.com with SMTP id 3so32565601vsq.7 for ; Tue, 03 Jan 2023 10:17:20 -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.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:20 -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=ZkEGcogj27YdFJQTywgiITgHI/jXlYMGF8YkSZKNLjc=; b=OdlkCUnO2Uxx0rv9SDJotaMqmCzirnX5oBoMpMo/v1Uw7jhHH+ekq6g2BOUT4oeXyn G3MEdy4bTs5ffpx7XDwZj6XhFdrTrzqo95Z1QcJlKbnG7SsxzwQZvZE1Wo3FO28GKIiq 5jHtEPyCri0F9Y2uSoqLeQ5J222QljYl5WuodTf2xC9eBagiWEv3s/xWR5t/h6g2CPJA 0bTa6yG9SV6uUdncWfiKfYELr+9OH46KM7l7AQW4VsNBgtXoZ9yaB/CJvtl5fomgcLGJ hzaHRORr6i/G/BWJVPnVIHL8/TqGN19Lo0iwb8ZKU/4LCW8R07v0kXLLJ0XVkRmi3ylK m1Dg== 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=ZkEGcogj27YdFJQTywgiITgHI/jXlYMGF8YkSZKNLjc=; b=G64KBnVII10g88QJPyptDnUlO5EFN+sIXfXG22OJEMvXCvEED59R2D5UfUXpEv+Iat 0jHhixrbkZXM9ugw/IhQey/vm5uRZ3/bucc+oUtEGiRDBTyslX+k9ZC2gYvEMaX/H1mx iJPCOj7t5pT5G2/4hCZtWJ0tzi39XPOSNdDHQEKTP3OlSArifoK2HZLyjIK2U5wtMFgh UlcDtmhCg36CsXKiHFggG/d0Hhw69wQbQh3Bh6bBnUlNJjAPa6u28uFBwieltjmQf+sZ eL33v3lmQySY6AyJbPN72hEHgkcopWD1EiWZobZYBuGW6oOxLHAZ7YVrRk8aIteQi2gG WBpg== X-Gm-Message-State: AFqh2kpjof7gHK/NZC9bSXZo51g7FFOJMYIIL1kB39JYqjsCZywZqCSK pfraG4ji6u/gplIhSPh47dYyhjGmUpRoJ6x3TZE= X-Google-Smtp-Source: AMrXdXulXRq4YTSV3PqtwEHk332qbByKrxYBsP/FA10Oxln8D6n0j5Ka6T0U91sjXmTX+nQ3lm5/qg== X-Received: by 2002:a67:fb0d:0:b0:3c9:27b2:3f04 with SMTP id d13-20020a67fb0d000000b003c927b23f04mr14482397vsr.32.1672769840511; Tue, 03 Jan 2023 10:17:20 -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 10/40] target/arm: Copy dtb_compatible from ARMCPUClass Date: Tue, 3 Jan 2023 10:16:16 -0800 Message-Id: <20230103181646.55711-11-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::e2f; envelope-from=richard.henderson@linaro.org; helo=mail-vs1-xe2f.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770300928100003 Content-Type: text/plain; charset="utf-8" Move the default initialization of dtb_compatible to arm_cpu_class_init, and copy back to the instance in arm_cpu_init. Further class overrides will come in a future patch. Signed-off-by: Richard Henderson --- target/arm/cpu-qom.h | 3 +++ target/arm/cpu.c | 15 ++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h index 057978b9db..5509ef9d85 100644 --- a/target/arm/cpu-qom.h +++ b/target/arm/cpu-qom.h @@ -71,6 +71,9 @@ struct ARMCPUClass { const ARMCPUInfo *info; DeviceRealize parent_realize; ResettablePhases parent_phases; + + /* 'compatible' string for this CPU for Linux device trees */ + const char *dtb_compatible; }; =20 void register_cp_regs_for_features(ARMCPU *cpu); diff --git a/target/arm/cpu.c b/target/arm/cpu.c index a6c6916f36..1bc45b2b25 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1181,6 +1181,7 @@ uint64_t arm_cpu_mp_affinity(int idx, uint8_t cluster= sz) static void arm_cpu_initfn(Object *obj) { ARMCPU *cpu =3D ARM_CPU(obj); + ARMCPUClass *acc =3D ARM_CPU_GET_CLASS(cpu); =20 cpu_set_cpustate_pointers(cpu); cpu->cp_regs =3D g_hash_table_new_full(g_direct_hash, g_direct_equal, @@ -1189,6 +1190,8 @@ static void arm_cpu_initfn(Object *obj) QLIST_INIT(&cpu->pre_el_change_hooks); QLIST_INIT(&cpu->el_change_hooks); =20 + cpu->dtb_compatible =3D acc->dtb_compatible; + #ifdef CONFIG_USER_ONLY # ifdef TARGET_AARCH64 /* @@ -1220,11 +1223,6 @@ static void arm_cpu_initfn(Object *obj) "pmu-interrupt", 1); #endif =20 - /* DTB consumers generally don't in fact care what the 'compatible' - * string is, so always provide some string and trust that a hypotheti= cal - * picky DTB consumer will also provide a helpful error message. - */ - cpu->dtb_compatible =3D "qemu,unknown"; cpu->psci_version =3D QEMU_PSCI_VERSION_0_1; /* By default assume PSCI= v0.1 */ cpu->kvm_target =3D QEMU_KVM_ARM_TARGET_NONE; =20 @@ -2243,6 +2241,13 @@ static void arm_cpu_class_init(ObjectClass *oc, void= *data) #ifdef CONFIG_TCG cc->tcg_ops =3D &arm_tcg_ops; #endif /* CONFIG_TCG */ + + /* + * DTB consumers generally don't in fact care what the 'compatible' + * string is, so always provide some string and trust that a hypotheti= cal + * picky DTB consumer will also provide a helpful error message. + */ + acc->dtb_compatible =3D "qemu,unknown"; } =20 static void arm_cpu_leaf_class_init(ObjectClass *oc, void *data) --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672769973; cv=none; d=zohomail.com; s=zohoarc; b=iKF5eCd1bgHjhclqdqFESiF5y4D648LuTbUPl4h+tRcUJrGKHo0mPuvbwex70J6uWzpUkl/Dhfh2dOAbb8/t1D6F/8BOWKFeLOe9z8NkhxJA+mSweq0uZkW/ogozXfRm4tmeZHSTeiIuo3JanJO9M+YDhgCrXY33FJkmW7lXeq8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672769973; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/p9QPpDGvjmZI1N9rUlYvW7qA56IptLsG0qWqJxJf9I=; b=VQTouv3Nopb5kBiTFikTxRMOjvllELUrH++3Eh5lUz/tzMuIa0OuCenEjdQJDgy29sQEGNFHd2z5FfzLIsPjh7PIrbKBsQyYG15v55+/gHgWchsXcnfyXOgpPTv9SD7+4HQRC+DEfG9rH6heOMbVxclmw1jJ563GHMgweS0NLcs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672769973635502.6734310444609; Tue, 3 Jan 2023 10:19:33 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClra-00007G-J5; Tue, 03 Jan 2023 13:18:14 -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 1pClqo-0008IO-BK for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:42 -0500 Received: from mail-vs1-xe30.google.com ([2607:f8b0:4864:20::e30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClqm-00057M-Hb for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:25 -0500 Received: by mail-vs1-xe30.google.com with SMTP id l184so3938290vsc.0 for ; Tue, 03 Jan 2023 10:17:23 -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.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:22 -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=/p9QPpDGvjmZI1N9rUlYvW7qA56IptLsG0qWqJxJf9I=; b=FRR2GH0Ag6gj3iHFzxmsL/UHVe5qEhqxClc1uJ3QWSh7AAO9wsb2vin2LaRL34NG2I fwxer1mWD/I0C2vh/IAyUm/PS/13feGKmMyOPCBwPgc66bEqtPpOmzQkNowWCs7d44gp 72cxSd2DYZFIS/Qi18wnHjL33SeiKpzNmSa2qmKDVOeLN6z04OmwVnTEHZShIvk8XCoJ QWlYQpQQAH9mPgvEjwv2JWM50jOJXVM1tU+fEmaibVtHMMtuJfKPlSUo+ivsno8YOjiC 3onzly0HalKP7Cq57VXFgVlXnMLYoqooVrSY0hLpGIHU8sgYmV6md2VqUDYZPc80/7PQ FexA== 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=/p9QPpDGvjmZI1N9rUlYvW7qA56IptLsG0qWqJxJf9I=; b=zHxIqvsL5Xy0LB9lAm4IshT8georiAP0TPI1m28+980kgrLexrNR2cHBK+BcjAl/mv EMz0NKc45HRnNuhl7VSuNNzxAsPE1X8BPjVU2HFcuLQ9biz2DaJhsot1CyI7gvH25CkH /o7MhOZNx+GW6CSz1WTagDfKpxJWIYydc8Ol1MTeSW8jWjF3HcEp/5WhyzQkvn6kLQFi waiEyONUjc8Dldl4mTWrLxIUgR74yzsYFHJWib1J52n1311krNQdmEEkFMS810UB4XEs r+HnohNNz3vnIV9rehAVDdgvDDufJHXh5TMGorG7Sy7WTDnoVS7Xna8e+l2fhCZ/GA/k 9y/A== X-Gm-Message-State: AFqh2kq1MppBCdpBVohl+elPCT+vkG1BryOlkBrTNbC4JELoH9+viyim bkceKxH+AfD69YpZaDNXY9lxGfFZZM1/QekJUDA= X-Google-Smtp-Source: AMrXdXvuwEoT3bE7aDRImdxticCXfZE+ZwLkn4Lfr3ge6aKhmWppbBjSdtowmcqCYqbwt79TAPev6w== X-Received: by 2002:a67:2681:0:b0:3c4:997b:667b with SMTP id m123-20020a672681000000b003c4997b667bmr15874643vsm.6.1672769843258; Tue, 03 Jan 2023 10:17:23 -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 11/40] target/arm: Copy features from ARMCPUClass Date: Tue, 3 Jan 2023 10:16:17 -0800 Message-Id: <20230103181646.55711-12-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::e30; envelope-from=richard.henderson@linaro.org; helo=mail-vs1-xe30.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672769974726100001 Content-Type: text/plain; charset="utf-8" Create a features member in ARMCPUClass and copy to the instance in arm_cpu_init. Settings of this value will come in a future patch. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/cpu-qom.h | 18 ++++++++++++++++++ target/arm/cpu.c | 1 + 2 files changed, 19 insertions(+) diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h index 5509ef9d85..ac58cc3a87 100644 --- a/target/arm/cpu-qom.h +++ b/target/arm/cpu-qom.h @@ -74,8 +74,26 @@ struct ARMCPUClass { =20 /* 'compatible' string for this CPU for Linux device trees */ const char *dtb_compatible; + + /* Internal CPU feature flags. */ + uint64_t features; }; =20 +static inline int arm_class_feature(ARMCPUClass *acc, int feature) +{ + return (acc->features & (1ULL << feature)) !=3D 0; +} + +static inline void set_class_feature(ARMCPUClass *acc, int feature) +{ + acc->features |=3D 1ULL << feature; +} + +static inline void unset_class_feature(ARMCPUClass *acc, int feature) +{ + acc->features &=3D ~(1ULL << feature); +} + void register_cp_regs_for_features(ARMCPU *cpu); void init_cpreg_list(ARMCPU *cpu); =20 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 1bc45b2b25..d64b86b6a5 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1191,6 +1191,7 @@ static void arm_cpu_initfn(Object *obj) QLIST_INIT(&cpu->el_change_hooks); =20 cpu->dtb_compatible =3D acc->dtb_compatible; + cpu->env.features =3D acc->features; =20 #ifdef CONFIG_USER_ONLY # ifdef TARGET_AARCH64 --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770359; cv=none; d=zohomail.com; s=zohoarc; b=RKZwj5nAuJBf3UdGAu5PTV8lV72/W9DvjVokYpHOyGlGIuZ4YFsHZ/xGXrVICHXy+TJg8/u24hmL6XnBbVhsNQSqe0ir4lnw3WgiGBSDm+ZtuHvoHyuqJHin63k0gn7zzca1bYdQoM4JKdTfHQ5CGTrkAsVtKzjRa2IFUFs36cI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770359; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=TF6WRrkDyTJgx1M6YcuNUMdyG++qDPJUqtoWjJFxRL0=; b=U7IFLw/MaK3r0IsCcqAakeycXvzrhmF8rF6sj/sPYHhJmlqNirN/EJLUGG0eDJQo7a5D/UQAbp2Jt6TZv6lvOu2hORek6YHWMWCXd5XeDTYsM8PHn9qxExsoL79/dwcRuphZU6TOuSktyg97X0Y7z7XdKU7qTll3n9WqPX0MICI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770359738593.2316933249151; Tue, 3 Jan 2023 10:25:59 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrb-00009D-CR; Tue, 03 Jan 2023 13:18:15 -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 1pClqr-0008Ig-Ob for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:40 -0500 Received: from mail-vk1-xa2b.google.com ([2607:f8b0:4864:20::a2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClqp-0005Dd-Hc for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:29 -0500 Received: by mail-vk1-xa2b.google.com with SMTP id i32so9064913vkr.12 for ; Tue, 03 Jan 2023 10:17:26 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:25 -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=TF6WRrkDyTJgx1M6YcuNUMdyG++qDPJUqtoWjJFxRL0=; b=y0JuM+N+f/Hd8F57ouZx9FQ/H1C2SdE/yfbdFioFjlBvfmdX3cGPQbN4Rih6w+XifV nOAuXXU75vl+2K0YJeu3ItYo0TFFVgwngb0vt3UD13B+4FnhyGh0DV38NkWhnhGibQan ZsKfIjb6+MCgwvgTBWNP62wPqY95/IeaDGGnlSD2PIEahNjELttedv939ZfYwVU9mjwS evhxuENGECzbW9RTFM4BIgWMLpAR5DZc+3HFEd7f+zT7vIegbLIOhC4krH/oI6ALi+Ma QVz/60On0SwsF7mFaBBhmPtvmaFOBftSxeJe9asv88lRSB6IkViVuZrSzXAsGayBEBuK pNsg== 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=TF6WRrkDyTJgx1M6YcuNUMdyG++qDPJUqtoWjJFxRL0=; b=8DbQh/jX/2/QeriUFxEGilYkkuxiNrKjifLCydVFdY+fp2rTjZG/Aolh7LwlAlgCzj PIWoXALpr4lHn4qL/Ah2ny50awDneuhHPhYONBeeju+I+DLc8M8+1ArW8A81i/0915Rp x88vDlP6GXSUkh3G1CWIczTxptyA8lUy2QXdoSuPMPKMcPCJAcs0SeVq2e17XGLWxPi0 fPB5jIKPhjkrM082H4+LRTR41VcqlE+YBg5jRl/mxIWUUvpJuveJkY7TBuG30kYOHGHe VlyKh7rmHlRgpIO2ada0/BnZHwVmIMqLliptgZ+mzIKfASNKqwpCcDCe9DYkKCmrnlgY FGcA== X-Gm-Message-State: AFqh2krERelBu8StWCbjX96g0Z2APoaAckl6w3vWbcHa9Nv0ALeetvDm jlaARAXoMR85hnT84UMD5GplKp2crHTtG5lZroc= X-Google-Smtp-Source: AMrXdXu6dJKn2tJbpue4xVKov0GKS14dm/EbCMwn5DXHYwdPNq1lr9BTNoo9SEX0NFWfUMXBdJ+KKA== X-Received: by 2002:a1f:2186:0:b0:3d5:53dc:2a91 with SMTP id h128-20020a1f2186000000b003d553dc2a91mr13637348vkh.14.1672769846028; Tue, 03 Jan 2023 10:17:26 -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 12/40] target/arm: Copy isar and friends from ARMCPUClass Date: Tue, 3 Jan 2023 10:16:18 -0800 Message-Id: <20230103181646.55711-13-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::a2b; envelope-from=richard.henderson@linaro.org; helo=mail-vk1-xa2b.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770361304100003 Content-Type: text/plain; charset="utf-8" Create a block of cpregs in ARMCPUClass and copy to the instance in arm_cpu_init. Settings of these values will come in a future patch. Signed-off-by: Richard Henderson --- target/arm/cpu-qom.h | 98 ++++++++++++++++++++++++++++++++++++++++++++ target/arm/cpu.h | 43 ++----------------- target/arm/cpu.c | 28 ++++++++++++- 3 files changed, 128 insertions(+), 41 deletions(-) diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h index ac58cc3a87..832b2cccf9 100644 --- a/target/arm/cpu-qom.h +++ b/target/arm/cpu-qom.h @@ -56,6 +56,45 @@ static inline void aarch64_cpu_register(const ARMCPUInfo= *info) arm_cpu_register_parent(info, TYPE_AARCH64_CPU); } =20 +typedef struct ARMISARegisters { + uint32_t id_isar0; + uint32_t id_isar1; + uint32_t id_isar2; + uint32_t id_isar3; + uint32_t id_isar4; + uint32_t id_isar5; + uint32_t id_isar6; + uint32_t id_mmfr0; + uint32_t id_mmfr1; + uint32_t id_mmfr2; + uint32_t id_mmfr3; + uint32_t id_mmfr4; + uint32_t id_mmfr5; + uint32_t id_pfr0; + uint32_t id_pfr1; + uint32_t id_pfr2; + uint32_t mvfr0; + uint32_t mvfr1; + uint32_t mvfr2; + uint32_t id_dfr0; + uint32_t id_dfr1; + uint32_t dbgdidr; + uint32_t dbgdevid; + uint32_t dbgdevid1; + uint64_t id_aa64isar0; + uint64_t id_aa64isar1; + uint64_t id_aa64pfr0; + uint64_t id_aa64pfr1; + uint64_t id_aa64mmfr0; + uint64_t id_aa64mmfr1; + uint64_t id_aa64mmfr2; + uint64_t id_aa64dfr0; + uint64_t id_aa64dfr1; + uint64_t id_aa64zfr0; + uint64_t id_aa64smfr0; + uint64_t reset_pmcr_el0; +} ARMISARegisters; + /** * ARMCPUClass: * @parent_realize: The parent class' realize handler. @@ -77,6 +116,65 @@ struct ARMCPUClass { =20 /* Internal CPU feature flags. */ uint64_t features; + + /* + * The instance init functions for implementation-specific subclasses + * set these fields to specify the implementation-dependent values of + * various constant registers and reset values of non-constant + * registers. + * Some of these might become QOM properties eventually. + * Field names match the official register names as defined in the + * ARMv7AR ARM Architecture Reference Manual. A reset_ prefix + * is used for reset values of non-constant registers; no reset_ + * prefix means a constant register. + * Some of these registers are split out into a substructure that + * is shared with the translators to control the ISA. + * + * Note that if you add an ID register to the ARMISARegisters struct + * you need to also update the 32-bit and 64-bit versions of the + * kvm_arm_get_host_cpu_features() function to correctly populate the + * field by reading the value from the KVM vCPU. + */ + ARMISARegisters isar; + + uint64_t midr; + uint64_t ctr; + uint64_t pmceid0; + uint64_t pmceid1; + uint64_t id_aa64afr0; + uint64_t id_aa64afr1; + uint64_t clidr; + /* + * The elements of this array are the CCSIDR values for each cache, + * in the order L1DCache, L1ICache, L2DCache, L2ICache, etc. + */ + uint64_t ccsidr[16]; + + uint32_t revidr; + uint32_t id_afr0; + uint32_t reset_fpsid; + uint32_t reset_sctlr; + uint32_t reset_auxcr; + + /* PMSAv7 MPU number of supported regions */ + uint32_t pmsav7_dregion; + /* v8M SAU number of supported regions */ + uint32_t sau_sregion; + + /* DCZ blocksize, in log_2(words), ie low 4 bits of DCZID_EL0 */ + uint32_t dcz_blocksize; + + /* Configurable aspects of GIC cpu interface (which is part of the CPU= ) */ + int gic_num_lrs; /* number of list registers */ + int gic_vpribits; /* number of virtual priority bits */ + int gic_vprebits; /* number of virtual preemption bits */ + int gic_pribits; /* number of physical priority bits */ + + /* + * [QEMU_]KVM_ARM_TARGET_* constant for this CPU, or + * QEMU_KVM_ARM_TARGET_NONE if the kernel doesn't support this CPU typ= e. + */ + uint32_t kvm_target; }; =20 static inline int arm_class_feature(ARMCPUClass *acc, int feature) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 3ac650092f..2d9bddf197 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -799,8 +799,6 @@ typedef enum ARMPSCIState { PSCI_ON_PENDING =3D 2 } ARMPSCIState; =20 -typedef struct ARMISARegisters ARMISARegisters; - /* * In map, each set bit is a supported vector length of (bit-number + 1) *= 16 * bytes, i.e. each bit number + 1 is the vector length in quadwords. @@ -967,44 +965,7 @@ struct ArchCPU { * kvm_arm_get_host_cpu_features() function to correctly populate the * field by reading the value from the KVM vCPU. */ - struct ARMISARegisters { - uint32_t id_isar0; - uint32_t id_isar1; - uint32_t id_isar2; - uint32_t id_isar3; - uint32_t id_isar4; - uint32_t id_isar5; - uint32_t id_isar6; - uint32_t id_mmfr0; - uint32_t id_mmfr1; - uint32_t id_mmfr2; - uint32_t id_mmfr3; - uint32_t id_mmfr4; - uint32_t id_mmfr5; - uint32_t id_pfr0; - uint32_t id_pfr1; - uint32_t id_pfr2; - uint32_t mvfr0; - uint32_t mvfr1; - uint32_t mvfr2; - uint32_t id_dfr0; - uint32_t id_dfr1; - uint32_t dbgdidr; - uint32_t dbgdevid; - uint32_t dbgdevid1; - uint64_t id_aa64isar0; - uint64_t id_aa64isar1; - uint64_t id_aa64pfr0; - uint64_t id_aa64pfr1; - uint64_t id_aa64mmfr0; - uint64_t id_aa64mmfr1; - uint64_t id_aa64mmfr2; - uint64_t id_aa64dfr0; - uint64_t id_aa64dfr1; - uint64_t id_aa64zfr0; - uint64_t id_aa64smfr0; - uint64_t reset_pmcr_el0; - } isar; + ARMISARegisters isar; uint64_t midr; uint32_t revidr; uint32_t reset_fpsid; @@ -4346,5 +4307,7 @@ static inline bool isar_feature_any_evt(const ARMISAR= egisters *id) */ #define cpu_isar_feature(name, cpu) \ ({ ARMCPU *cpu_ =3D (cpu); isar_feature_##name(&cpu_->isar); }) +#define class_isar_feature(name, acc) \ + ({ ARMCPUClass *acc_ =3D (acc); isar_feature_##name(&acc_->isar); }) =20 #endif diff --git a/target/arm/cpu.c b/target/arm/cpu.c index d64b86b6a5..8463c45d87 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1192,6 +1192,32 @@ static void arm_cpu_initfn(Object *obj) =20 cpu->dtb_compatible =3D acc->dtb_compatible; cpu->env.features =3D acc->features; + cpu->isar =3D acc->isar; + + cpu->midr =3D acc->midr; + cpu->ctr =3D acc->ctr; + cpu->pmceid0 =3D acc->pmceid0; + cpu->pmceid1 =3D acc->pmceid1; + cpu->id_aa64afr0 =3D acc->id_aa64afr0; + cpu->id_aa64afr1 =3D acc->id_aa64afr1; + cpu->clidr =3D acc->clidr; + + QEMU_BUILD_BUG_ON(sizeof(cpu->ccsidr) !=3D sizeof(acc->ccsidr)); + memcpy(cpu->ccsidr, acc->ccsidr, sizeof(acc->ccsidr)); + + cpu->revidr =3D acc->revidr; + cpu->id_afr0 =3D acc->id_afr0; + cpu->reset_fpsid =3D acc->reset_fpsid; + cpu->reset_sctlr =3D acc->reset_sctlr; + cpu->reset_auxcr =3D acc->reset_auxcr; + cpu->pmsav7_dregion =3D acc->pmsav7_dregion; + cpu->sau_sregion =3D acc->sau_sregion; + cpu->dcz_blocksize =3D acc->dcz_blocksize; + cpu->gic_num_lrs =3D acc->gic_num_lrs; + cpu->gic_vpribits =3D acc->gic_vpribits; + cpu->gic_vprebits =3D acc->gic_vprebits; + cpu->gic_pribits =3D acc->gic_pribits; + cpu->kvm_target =3D acc->kvm_target; =20 #ifdef CONFIG_USER_ONLY # ifdef TARGET_AARCH64 @@ -1225,7 +1251,6 @@ static void arm_cpu_initfn(Object *obj) #endif =20 cpu->psci_version =3D QEMU_PSCI_VERSION_0_1; /* By default assume PSCI= v0.1 */ - cpu->kvm_target =3D QEMU_KVM_ARM_TARGET_NONE; =20 if (tcg_enabled() || hvf_enabled()) { /* TCG and HVF implement PSCI 1.1 */ @@ -2249,6 +2274,7 @@ static void arm_cpu_class_init(ObjectClass *oc, void = *data) * picky DTB consumer will also provide a helpful error message. */ acc->dtb_compatible =3D "qemu,unknown"; + acc->kvm_target =3D QEMU_KVM_ARM_TARGET_NONE; } =20 static void arm_cpu_leaf_class_init(ObjectClass *oc, void *data) --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770470; cv=none; d=zohomail.com; s=zohoarc; b=BBEittMYDSCf/iaXTYwvWyrOPyeeamLOguKTE9SuXq8IxwMIYrNSVZ2HATRbp1rvvZWLoIGPIQTYsMpxJXFD4XWHgASMkssuDSsfUiv+t7asTFg6S9eno0v5ur5IlRy0M0sZBvzcU62nn66NvUG9Qc8Rj5fLXRmFZP1Lxwon0xw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770470; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=rb9AmI85idWoLsBzV+dL4jn39dqWdimKW4r1L8TYKqA=; b=Fg6O5ZoYC2wZfOKfOrYg7ZrHxRVzo2zSsTeOE8KaFPq129O8GvzWebjOZTtLPwjkW+dTDwvLBXSUUyPV0R1+y6U7A7FKCnpxZQ6LGJkyuj9LDgvoUNrOqhkfvJAbIfVNMwzzfuX+VNafMVEdyKv9dWcln1nMKj2MBkVo1UnoJxo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167277047028116.84939873428334; Tue, 3 Jan 2023 10:27:50 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClra-00007M-Ij; Tue, 03 Jan 2023 13:18:14 -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 1pClqt-0008Iq-KF for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:39 -0500 Received: from mail-vs1-xe2f.google.com ([2607:f8b0:4864:20::e2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClqr-0005C0-K1 for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:30 -0500 Received: by mail-vs1-xe2f.google.com with SMTP id 3so32566037vsq.7 for ; Tue, 03 Jan 2023 10:17:29 -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.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:28 -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=rb9AmI85idWoLsBzV+dL4jn39dqWdimKW4r1L8TYKqA=; b=pfzsU4hUS7eJ60VWnkOCuLpaIRDZXdbEFaIqCvOsgmTbMyCr0GswzE1AQchfGtB/j5 YkjFai8/QXqMczksbZHDRj5d0UZNYsZY7gOKEs1KsGoKv25aTatLLWWM4WHHr3bo8J/2 WukTFFKYgIfI+zw+vtK4JIuxmvcjy5huRJgqZZfrxTHshROpczXxIYmex3i3xUqnuKQ7 oMS42Fedlmmj491FUYzjztVxNCeZxu+3fppd9+gZxp0Rl2QkXJpiD1oVYPH9s38jWuwG EeYL7jGP6eU+QoQIf+Ot23U3qKFKVluk7PzxGHjF0dMXXHIrO6yiHBEUCrPxMXcRMynU zR4Q== 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=rb9AmI85idWoLsBzV+dL4jn39dqWdimKW4r1L8TYKqA=; b=ad3fsIJEQJO1ANSUQ5g+YUohlLoDWa/H/26TQDXFdYS9I7brxBvwB0QxNJ9vUv9eJn TUJuBumOYdAv5r8Dblr2IFMtz9Lb3ioh1k7wAQjZ7NUtI5DdjB/v40lBOf6vDSq+7Ry4 ZALgiRAuVA3CkpQg0Qze+BNWY93orTir35FKE+LOoVMNnn0OkwfDWGo/mm93LsUVRUA4 lqL6KO0uJ7jNSgqZSwq5+/OYPM4a9CXIa0QX53gfj75hJJNwYTNO4sMPRVsSm5iOlzw1 +d75Eh89KBrpCt2wN1eUN25mzRFJMU5PmXtOEmAqT+OlYArYTEdf81QbAzGnXXIHurbI z1bQ== X-Gm-Message-State: AFqh2kqLEqteeGpPL0a50ra1PMFX7Z+sJiItKfNXH8ooooVW09XnSAXm TcVDcMdMFcqafhCkzFQUbBeJzI376WnfM8/e7OM= X-Google-Smtp-Source: AMrXdXuv2vDhEVghaGj6c6LAnjAVxB7rcj4D40U3MPuXXL8PPDMJ+aY13z2JjP+G2LdNmMF8sANNeA== X-Received: by 2002:a67:e983:0:b0:3ce:8419:3cb7 with SMTP id b3-20020a67e983000000b003ce84193cb7mr4983696vso.5.1672769848845; Tue, 03 Jan 2023 10:17:28 -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 13/40] hw/arm/bcm2836: Set mp-affinity property in realize Date: Tue, 3 Jan 2023 10:16:19 -0800 Message-Id: <20230103181646.55711-14-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::e2f; envelope-from=richard.henderson@linaro.org; helo=mail-vs1-xe2f.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770471871100003 Content-Type: text/plain; charset="utf-8" There was even a TODO comment that we ought to be using a cpu property, but we failed to update when the property was added. Use ARM_AFF1_SHIFT instead of the bare constant 8. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/arm/bcm2836.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/hw/arm/bcm2836.c b/hw/arm/bcm2836.c index 24354338ca..abbb3689d0 100644 --- a/hw/arm/bcm2836.c +++ b/hw/arm/bcm2836.c @@ -130,8 +130,11 @@ static void bcm2836_realize(DeviceState *dev, Error **= errp) qdev_get_gpio_in_named(DEVICE(&s->control), "gpu-fiq", 0)); =20 for (n =3D 0; n < BCM283X_NCPUS; n++) { - /* TODO: this should be converted to a property of ARM_CPU */ - s->cpu[n].core.mp_affinity =3D (bc->clusterid << 8) | n; + if (!object_property_set_int(OBJECT(&s->cpu[n].core), "mp-affinity= ", + (bc->clusterid << ARM_AFF1_SHIFT) | n, + errp)) { + return; + } =20 /* set periphbase/CBAR value for CPU-local registers */ if (!object_property_set_int(OBJECT(&s->cpu[n].core), "reset-cbar", --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770575; cv=none; d=zohomail.com; s=zohoarc; b=bTHnL2dK5f+qlGSyZMqyUqXWBaN+qVi+VGpzDnCFCTFtsxFK7t7p67Ea5RwioQpwY8VDydCH3Rcff2PJ41Gp54Rq89PMCHcPuKniPpzshf+8xVmAdAjdFVmx+hsFB8R+RD3t+gePGAnZYqO/GOjLOfijR05j9S57Al+YJfpBvkI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770575; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=JCltR3KinAgd2uF6C+01owj+mYF2uDzhF9nMarGDJGo=; b=F4trXextYoi/j7P1PgXhj0xs4Tp3FrLZBTyQ+Ez+2MoOJfBrR+HcVGN+S8R0C9Fn3c1kA6KEG2fdY9d+vjn9VAJmKpVc34T1Wgbu/karkKIRhnbKkktHActpeaERGAXB1D4kJtv2lYXelT1MQuYRGF8Wv77I1Y7FSIzOhet23B8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770575027833.1383473808063; Tue, 3 Jan 2023 10:29:35 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrX-0008Th-KW; Tue, 03 Jan 2023 13:18: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 1pClqw-0008Iw-V0 for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:41 -0500 Received: from mail-vk1-xa2a.google.com ([2607:f8b0:4864:20::a2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClqu-0005EO-M6 for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:33 -0500 Received: by mail-vk1-xa2a.google.com with SMTP id n205so8663272vkf.13 for ; Tue, 03 Jan 2023 10:17:32 -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.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:31 -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=JCltR3KinAgd2uF6C+01owj+mYF2uDzhF9nMarGDJGo=; b=X+zQqDX8Ddq0L+t7pqSYvm/voixbduZ09pXLbG4XglTYcHqYH+l12o/qSO6g3BvQ0M /z+nHnsNsXUDRFWu0jmfmI3jGeeobFTekNN7lb/083UHOTkNF9ffEq6z4wVVPL9Bts34 xILEFR208pJs92Jjz1Ncd8ja6azjJBZDS8hd9BfbuNq0czdB9F2PycjobOZYX6EuBqpu uGa/p4/EI8KWU2UjawKsvKnUgRYx2Msg+zO7saYf3KOTulzBoRc4N0Fv+XFPmNHkO/S8 Fcn2hpV9LwvgpmOKN2mRZPtxblliaSmkb3HsKxYradx5g9J2zaSZe7k6A2gbkA503hWJ fLVA== 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=JCltR3KinAgd2uF6C+01owj+mYF2uDzhF9nMarGDJGo=; b=BX0pyBn671RBBXsURQX0zHY2nXC7sXAi0KYXS+ssxO9tGKLPN27gG7Qz7SYbRPuA6W iECWLJbWW0UKoL7DUTjtysbR0R3DqzuWXFJ4/4QLbLFX/yHbQCUfR/3E8OBBAGBfvfUk GZlFbEQjjeziqfKubuecL4mwBDvRpzth4+jg9RVyS1//f+4Y1yPtYVYfZFVcS4M1ER7q jFZwjtQHLJLQwxq/mpunQc9x9QyIhdAah4b0/Ldaa9AWlG4+IOJMmc+LgQ5UZMjgDdfj ceCT2I5bIUHSt3iSy0QS7iGFx6fpsTy20eSA++q8oVNLIqX0NvSLrMa2ZCCEI57oFqna kkHw== X-Gm-Message-State: AFqh2kr0jXDY7I8dEYMX+LjZ5bC0fu5t+AUnyocvV51DcwwEJV4CLrdm 9w5vc37LKhJHeBNSe5Wr0+90khQoZhiaZcRRoIw= X-Google-Smtp-Source: AMrXdXsWBFc1Aweg6OJd1TXb6zz3+Gbld47xhGsnINX5LGQmfP8X2FrCrd10Rutx5Dx4j4dLXC7bIw== X-Received: by 2002:a1f:3141:0:b0:3d1:b994:7c61 with SMTP id x62-20020a1f3141000000b003d1b9947c61mr18269237vkx.8.1672769851796; Tue, 03 Jan 2023 10:17:31 -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 14/40] target/arm: Rename arm_cpu_mp_affinity Date: Tue, 3 Jan 2023 10:16:20 -0800 Message-Id: <20230103181646.55711-15-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::a2a; envelope-from=richard.henderson@linaro.org; helo=mail-vk1-xa2a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770576569100001 Content-Type: text/plain; charset="utf-8" Rename to arm_build_mp_affinity. This frees up the name for other usage, and emphasizes that the cpu object is not involved. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/cpu.h | 2 +- hw/arm/npcm7xx.c | 2 +- hw/arm/sbsa-ref.c | 2 +- hw/arm/virt.c | 2 +- target/arm/cpu.c | 6 +++--- 5 files changed, 7 insertions(+), 7 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 2d9bddf197..dd72519fda 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1037,7 +1037,7 @@ struct ArchCPU { =20 unsigned int gt_cntfrq_period_ns(ARMCPU *cpu); =20 -uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz); +uint64_t arm_build_mp_affinity(int idx, uint8_t clustersz); =20 #ifndef CONFIG_USER_ONLY extern const VMStateDescription vmstate_arm_cpu; diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c index d85cc02765..41124b7444 100644 --- a/hw/arm/npcm7xx.c +++ b/hw/arm/npcm7xx.c @@ -462,7 +462,7 @@ static void npcm7xx_realize(DeviceState *dev, Error **e= rrp) /* CPUs */ for (i =3D 0; i < nc->num_cpus; i++) { object_property_set_int(OBJECT(&s->cpu[i]), "mp-affinity", - arm_cpu_mp_affinity(i, NPCM7XX_MAX_NUM_CPU= S), + arm_build_mp_affinity(i, NPCM7XX_MAX_NUM_C= PUS), &error_abort); object_property_set_int(OBJECT(&s->cpu[i]), "reset-cbar", NPCM7XX_GIC_CPU_IF_ADDR, &error_abort); diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c index 4bb444684f..06fd4b6fb0 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -165,7 +165,7 @@ static bool cpu_type_valid(const char *cpu) static uint64_t sbsa_ref_cpu_mp_affinity(SBSAMachineState *sms, int idx) { uint8_t clustersz =3D ARM_DEFAULT_CPUS_PER_CLUSTER; - return arm_cpu_mp_affinity(idx, clustersz); + return arm_build_mp_affinity(idx, clustersz); } =20 /* diff --git a/hw/arm/virt.c b/hw/arm/virt.c index ea2413a0ba..3642604dea 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -1700,7 +1700,7 @@ static uint64_t virt_cpu_mp_affinity(VirtMachineState= *vms, int idx) clustersz =3D GICV3_TARGETLIST_BITS; } } - return arm_cpu_mp_affinity(idx, clustersz); + return arm_build_mp_affinity(idx, clustersz); } =20 static inline bool *virt_get_high_memmap_enabled(VirtMachineState *vms, diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 8463c45d87..a104a77165 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1171,7 +1171,7 @@ static void arm_cpu_dump_state(CPUState *cs, FILE *f,= int flags) } } =20 -uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz) +uint64_t arm_build_mp_affinity(int idx, uint8_t clustersz) { uint32_t Aff1 =3D idx / clustersz; uint32_t Aff0 =3D idx % clustersz; @@ -1927,8 +1927,8 @@ static void arm_cpu_realizefn(DeviceState *dev, Error= **errp) * so these bits always RAZ. */ if (cpu->mp_affinity =3D=3D ARM64_AFFINITY_INVALID) { - cpu->mp_affinity =3D arm_cpu_mp_affinity(cs->cpu_index, - ARM_DEFAULT_CPUS_PER_CLUSTE= R); + cpu->mp_affinity =3D arm_build_mp_affinity(cs->cpu_index, + ARM_DEFAULT_CPUS_PER_CLUS= TER); } =20 if (cpu->reset_hivecs) { --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672769931; cv=none; d=zohomail.com; s=zohoarc; b=E9PlXggddvDWKHfXOqOvBXBDTdaccO7df3HSpN/dPo0l90rrg0BxoVi9ZxfxOSR9B3mZ72l5WxwAaeqAz8pwPT7ajPQqRXLfg+2QxiPKg05JQ9dPZ6Qmc8a56XIZNaXGs1Dj2kfno/og7VbKVPviEqdpF1cxJZ7LCYbEay0YbP8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672769931; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Pmw60XZJkaURtg8eJBBrSmnGqjJDvsMLyRzbxcUBtvE=; b=mHHKrEWf76EcVeZWfjg/gTE3qGC5S+kaEjW2ZvGzfsxyoMDrlw/j1sRAhMv/NzGwkjq/TR5c/XcXiWUtdJnjzRpnlU4uyhZqxC0QIvERjt82oJ8kXXFdQ7kzFkDaA4U4fUmWY4aGLyYPNqOcuQxjmkvZPoDoVhBokZ1UNV2sbg0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672769931215779.7795200689584; Tue, 3 Jan 2023 10:18:51 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrf-0000Iy-IL; Tue, 03 Jan 2023 13:18:19 -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 1pClr1-0008Ju-Kk for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:42 -0500 Received: from mail-yb1-xb30.google.com ([2607:f8b0:4864:20::b30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClqz-0005Eh-FL for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:39 -0500 Received: by mail-yb1-xb30.google.com with SMTP id 83so33160867yba.11 for ; Tue, 03 Jan 2023 10:17:35 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:34 -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=Pmw60XZJkaURtg8eJBBrSmnGqjJDvsMLyRzbxcUBtvE=; b=Qm55UOU3asWzTW1uAeuDFLJAey3+MCRxPgz3tOWphd4E8Yn//csomMhEWg4IZh7hRm Emi3ONbuuxcMAB+cW/WBptTH9FWB9ZH2ru3yICeQnm35Srzn2NlE1bBB85hHPJ1hYHmp F85LtQREfUXnKbODl7WsKw47zADZXOzuxA36s5hCNYGnASYfddDd6wnI9+7GoR/3Sybb rAnJ/a1NmULm1FyeRcr/wr7p0e85+NKuwPhFvY59qX324bsYJ9xMPwWcEsM8Wf6YeK1H Lin4825lvPzq55S8ilc/LOSLxfxa80mkPgrwbQgv9TrN2n/FXN8/TNWtgJk6w86hEglf fwBg== 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=Pmw60XZJkaURtg8eJBBrSmnGqjJDvsMLyRzbxcUBtvE=; b=toxWunf2iWnT+Gbo2I57JoaqzTSdjwzUToZ1TcudD4KAyRffitiVP7u9WUv58kX7wo mOF9vv/3yb4ZkPlm5Bprh1gNlUyNfc+6ST5W6IND7uh2YClmczT0grHOnUfS8IICwhAe KCi3x24LUCDvBQH2NTMXQxWVRHxI4QpdOrQzug91wYvkHnTUlBfcCFNlmunvZ4i/oWW3 t5zgp6GaoawoX1yi8/+mBJL2us5tD3ipuWGs0fTu9BeuYAQ00qtsRyR48jHU+7O8XDd9 uIr2TtJ9Hy0zu4cX8zhxlSU9+KgX1D9Y0ltpAgPiu4oCfrGhCWwSOEXihBVodTyLX6X1 dO9A== X-Gm-Message-State: AFqh2kqukfD6JSiyj9no6jKXNju3kybsknu6L7TS/hZhwq1uG9QJvGEt wMbC9jGE6a83MJdSAtCG7zSHMAxLZ89HgaG7XwA= X-Google-Smtp-Source: AMrXdXs3vEnJ2CWolHHXlNrYLqKi8DUdUUtW7kt4NKjNcrjNKS39jAcOPWnmyjCRlkqqWPduByuSwg== X-Received: by 2002:a25:bd0c:0:b0:767:b792:2a7e with SMTP id f12-20020a25bd0c000000b00767b7922a7emr35097941ybk.26.1672769854620; Tue, 03 Jan 2023 10:17:34 -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 15/40] target/arm: Create arm_cpu_mp_affinity Date: Tue, 3 Jan 2023 10:16:21 -0800 Message-Id: <20230103181646.55711-16-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::b30; envelope-from=richard.henderson@linaro.org; helo=mail-yb1-xb30.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672769932542100003 Content-Type: text/plain; charset="utf-8" Wrapper to return the mp affinity bits from the cpu. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/cpu.h | 5 +++++ hw/arm/virt-acpi-build.c | 2 +- hw/arm/virt.c | 6 +++--- hw/arm/xlnx-versal-virt.c | 3 ++- hw/misc/xlnx-versal-crl.c | 4 ++-- target/arm/arm-powerctl.c | 2 +- target/arm/hvf/hvf.c | 4 ++-- target/arm/psci.c | 2 +- 8 files changed, 17 insertions(+), 11 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index dd72519fda..499d2a6028 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1039,6 +1039,11 @@ unsigned int gt_cntfrq_period_ns(ARMCPU *cpu); =20 uint64_t arm_build_mp_affinity(int idx, uint8_t clustersz); =20 +static inline uint64_t arm_cpu_mp_affinity(ARMCPU *cpu) +{ + return cpu->mp_affinity; +} + #ifndef CONFIG_USER_ONLY extern const VMStateDescription vmstate_arm_cpu; =20 diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index 4156111d49..40fa3faf47 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -759,7 +759,7 @@ build_madt(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) build_append_int_noprefix(table_data, vgic_interrupt, 4); build_append_int_noprefix(table_data, 0, 8); /* GICR Base Addre= ss*/ /* MPIDR */ - build_append_int_noprefix(table_data, armcpu->mp_affinity, 8); + build_append_int_noprefix(table_data, arm_cpu_mp_affinity(armcpu),= 8); /* Processor Power Efficiency Class */ build_append_int_noprefix(table_data, 0, 1); /* Reserved */ diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 3642604dea..aed86997c0 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -391,7 +391,7 @@ static void fdt_add_cpu_nodes(const VirtMachineState *v= ms) for (cpu =3D 0; cpu < smp_cpus; cpu++) { ARMCPU *armcpu =3D ARM_CPU(qemu_get_cpu(cpu)); =20 - if (armcpu->mp_affinity & ARM_AFF3_MASK) { + if (arm_cpu_mp_affinity(armcpu) & ARM_AFF3_MASK) { addr_cells =3D 2; break; } @@ -418,10 +418,10 @@ static void fdt_add_cpu_nodes(const VirtMachineState = *vms) =20 if (addr_cells =3D=3D 2) { qemu_fdt_setprop_u64(ms->fdt, nodename, "reg", - armcpu->mp_affinity); + arm_cpu_mp_affinity(armcpu)); } else { qemu_fdt_setprop_cell(ms->fdt, nodename, "reg", - armcpu->mp_affinity); + arm_cpu_mp_affinity(armcpu)); } =20 if (ms->possible_cpus->cpus[cs->cpu_index].props.has_node_id) { diff --git a/hw/arm/xlnx-versal-virt.c b/hw/arm/xlnx-versal-virt.c index 37fc9b919c..50d983c239 100644 --- a/hw/arm/xlnx-versal-virt.c +++ b/hw/arm/xlnx-versal-virt.c @@ -104,7 +104,8 @@ static void fdt_add_cpu_nodes(VersalVirt *s, uint32_t p= sci_conduit) ARMCPU *armcpu =3D ARM_CPU(qemu_get_cpu(i)); =20 qemu_fdt_add_subnode(s->fdt, name); - qemu_fdt_setprop_cell(s->fdt, name, "reg", armcpu->mp_affinity); + qemu_fdt_setprop_cell(s->fdt, name, "reg", + arm_cpu_mp_affinity(armcpu)); if (psci_conduit !=3D QEMU_PSCI_CONDUIT_DISABLED) { qemu_fdt_setprop_string(s->fdt, name, "enable-method", "psci"); } diff --git a/hw/misc/xlnx-versal-crl.c b/hw/misc/xlnx-versal-crl.c index 767106b7a3..267aa55106 100644 --- a/hw/misc/xlnx-versal-crl.c +++ b/hw/misc/xlnx-versal-crl.c @@ -67,9 +67,9 @@ static void crl_reset_cpu(XlnxVersalCRL *s, ARMCPU *armcp= u, bool rst_old, bool rst_new) { if (rst_new) { - arm_set_cpu_off(armcpu->mp_affinity); + arm_set_cpu_off(arm_cpu_mp_affinity(armcpu)); } else { - arm_set_cpu_on_and_reset(armcpu->mp_affinity); + arm_set_cpu_on_and_reset(arm_cpu_mp_affinity(armcpu)); } } =20 diff --git a/target/arm/arm-powerctl.c b/target/arm/arm-powerctl.c index b75f813b40..5a6dfdfb83 100644 --- a/target/arm/arm-powerctl.c +++ b/target/arm/arm-powerctl.c @@ -36,7 +36,7 @@ CPUState *arm_get_cpu_by_id(uint64_t id) CPU_FOREACH(cpu) { ARMCPU *armcpu =3D ARM_CPU(cpu); =20 - if (armcpu->mp_affinity =3D=3D id) { + if (arm_cpu_mp_affinity(armcpu) =3D=3D id) { return cpu; } } diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 060aa0ccf4..e0ba91f5c6 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -645,7 +645,7 @@ static void hvf_raise_exception(CPUState *cpu, uint32_t= excp, =20 static void hvf_psci_cpu_off(ARMCPU *arm_cpu) { - int32_t ret =3D arm_set_cpu_off(arm_cpu->mp_affinity); + int32_t ret =3D arm_set_cpu_off(arm_cpu_mp_affinity(arm_cpu)); assert(ret =3D=3D QEMU_ARM_POWERCTL_RET_SUCCESS); } =20 @@ -674,7 +674,7 @@ static bool hvf_handle_psci_call(CPUState *cpu) int32_t ret =3D 0; =20 trace_hvf_psci_call(param[0], param[1], param[2], param[3], - arm_cpu->mp_affinity); + arm_cpu_mp_affinity(arm_cpu)); =20 switch (param[0]) { case QEMU_PSCI_0_2_FN_PSCI_VERSION: diff --git a/target/arm/psci.c b/target/arm/psci.c index 6c1239bb96..b49d406e39 100644 --- a/target/arm/psci.c +++ b/target/arm/psci.c @@ -215,7 +215,7 @@ err: return; =20 cpu_off: - ret =3D arm_set_cpu_off(cpu->mp_affinity); + ret =3D arm_set_cpu_off(arm_cpu_mp_affinity(cpu)); /* notreached */ /* sanity check in case something failed */ assert(ret =3D=3D QEMU_ARM_POWERCTL_RET_SUCCESS); --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770288; cv=none; d=zohomail.com; s=zohoarc; b=g2PsPFds4MeCQB98bmYvoRicuOrTIy0AC9o37XX1zNeFhmA+GPaTydqSgPwBW5bk6YGEiLsm6i9NEBsbIWP5bEm9YDuoipCTE3EkNQnL4i1qI5WBZPzZjiAT/vxWHjFbFvP5f8JuV3h53HW2DlRHmUFIEWJNvqaFNaJAdk7xEeM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770288; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=jHRFXnO9//MOeiq7qjJkKcDR9svz35fK7EmJ2XSeXDU=; b=MYdsig7AWu2ZUQvSVu0lzN49+vpH/l7b2RHzcM/RKrH873cwnoRHkG683hgZKDyAIfCL7IAB5FHqCQd+azS5IUYVCniiHny3+jblcK6RI7b7u4/NBmry/2xufAZ3Z9GJErjOGHIDJxRMj44UGtOAyNbh/j/g/HPCLui8vXBoi9g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770288427426.89955737246976; Tue, 3 Jan 2023 10:24:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrc-0000B3-9b; Tue, 03 Jan 2023 13:18:16 -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 1pClr3-0008KI-LA for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:42 -0500 Received: from mail-vs1-xe2e.google.com ([2607:f8b0:4864:20::e2e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClr1-0005Ez-EC for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:41 -0500 Received: by mail-vs1-xe2e.google.com with SMTP id s127so18615874vsb.5 for ; Tue, 03 Jan 2023 10:17:38 -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.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:36 -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=jHRFXnO9//MOeiq7qjJkKcDR9svz35fK7EmJ2XSeXDU=; b=gyNggrmqP7Y3wY8gBDJjpNvUmy2ZFqhl2pmnsUxTLFY+JFgSc0q4bT2YAsQ0ZaYTCo SwORgFaUwRK7K3bq4nS+aT+KeZ1Lk8V9C/3FeMG3ZVXYA2JrsIvtOWvkbPUTRCj9drfe bYSP21bFtl+1LNwbARVQRpDyBz5Cb496+1E46B+VkrIz1m845f4xDyy1mAFDJQyOUm7l Zl+OfY+xFXxd4S8LtQFiAcbpZkjSY/9YJw7spOp3ngmO3Xlsi/7P2maH9NQGQ5gomiTx NPAycoQNN6jPcR04p9xrTTghTB9G+4MFK7uw31Vfr0OuMAM1HacRac1mBGGHIMioCRpn Jjkg== 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=jHRFXnO9//MOeiq7qjJkKcDR9svz35fK7EmJ2XSeXDU=; b=DeBu4sSeusUqTdDEjTSqD2UrMvryuG3iUP6ECjO/DvQXuegfs4SwAJyU2aLGiQi7MK 4QUH9UVnR/47kI8ZLTfq/FQbxDwjp2nmImKE25DxB9/VKmEp+K3tQe97YV/kUILAxznw eIuuJezAss9ZCJMnjoq5eMFFviafF1zZ90BSImCK+1fJWnBDaF9wmsmRGu0AtN4IHL4t DZX/hvrIAmlBnhRKMth8VTrDOqQdPXb6lD0IjsIyR4lsvs5MmY9DKPgk6auMm+xLTQoO 8wnOPHUBhdKRzW/jirbkW3ylHPnuI/3PeYTiuyfBzjosJsm7h/P8o/dlEEFaT+bPUY2E ZYLA== X-Gm-Message-State: AFqh2kpAzdjIXHwCNtNG0ek1HOkstw7nsZRPdJSta5+TO91RDIfBH/K7 JoXnyXv3p34+RCeaGY6uLTmnPk10+f+YNnECPhQ= X-Google-Smtp-Source: AMrXdXuxftBVFd00nRvTlKMeBdgaQ+74BbEBZKBpbG7uZlF3N86YrkwZ30pa+l+eSIQFbtzkIVT9+g== X-Received: by 2002:a05:6102:a87:b0:3b1:4cea:cd4a with SMTP id n7-20020a0561020a8700b003b14ceacd4amr19789689vsg.17.1672769857130; Tue, 03 Jan 2023 10:17:37 -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 16/40] target/arm: Represent the entire MPIDR_EL1 Date: Tue, 3 Jan 2023 10:16:22 -0800 Message-Id: <20230103181646.55711-17-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::e2e; envelope-from=richard.henderson@linaro.org; helo=mail-vs1-xe2e.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770288831100001 Content-Type: text/plain; charset="utf-8" Replace ARMCPU.mp_affinity with CPUARMState.cp15.mpidr_el1, setting the additional bits as required. In particular, always set the U bit when there is only one cpu in the system. Remove the mp_is_up bit which attempted to do the same thing. Signed-off-by: Richard Henderson --- target/arm/cpu.h | 7 ++-- target/arm/cpu.c | 80 +++++++++++++++++++++++++++++++++++++------- target/arm/cpu_tcg.c | 1 - target/arm/helper.c | 25 ++------------ target/arm/hvf/hvf.c | 2 +- target/arm/kvm64.c | 4 +-- 6 files changed, 75 insertions(+), 44 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 499d2a6028..0c5b942ed0 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -935,9 +935,6 @@ struct ArchCPU { /* KVM steal time */ OnOffAuto kvm_steal_time; =20 - /* Uniprocessor system with MP extensions */ - bool mp_is_up; - /* True if we tried kvm_arm_host_cpu_features() during CPU instance_in= it * and the probe failed (so we need to report the error in realize) */ @@ -977,7 +974,7 @@ struct ArchCPU { uint64_t id_aa64afr0; uint64_t id_aa64afr1; uint64_t clidr; - uint64_t mp_affinity; /* MP ID without feature bits */ + uint64_t mpidr_el1; /* The elements of this array are the CCSIDR values for each cache, * in the order L1DCache, L1ICache, L2DCache, L2ICache, etc. */ @@ -1041,7 +1038,7 @@ uint64_t arm_build_mp_affinity(int idx, uint8_t clust= ersz); =20 static inline uint64_t arm_cpu_mp_affinity(ARMCPU *cpu) { - return cpu->mp_affinity; + return cpu->mpidr_el1 & ARM64_AFFINITY_MASK; } =20 #ifndef CONFIG_USER_ONLY diff --git a/target/arm/cpu.c b/target/arm/cpu.c index a104a77165..a46fa424d3 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1231,6 +1231,9 @@ static void arm_cpu_initfn(Object *obj) cpu->sme_default_vq =3D 2; # endif #else + /* To be set properly by either the board or by realize. */ + cpu->mpidr_el1 =3D ARM64_AFFINITY_INVALID; + /* Our inbound IRQ and FIQ lines */ if (kvm_enabled()) { /* VIRQ and VFIQ are unused with KVM but we add them to maintain @@ -1921,16 +1924,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Erro= r **errp) return; } =20 - /* This cpu-id-to-MPIDR affinity is used only for TCG; KVM will overri= de it. - * We don't support setting cluster ID ([16..23]) (known as Aff2 - * in later ARM ARM versions), or any of the higher affinity level fie= lds, - * so these bits always RAZ. - */ - if (cpu->mp_affinity =3D=3D ARM64_AFFINITY_INVALID) { - cpu->mp_affinity =3D arm_build_mp_affinity(cs->cpu_index, - ARM_DEFAULT_CPUS_PER_CLUS= TER); - } - if (cpu->reset_hivecs) { cpu->reset_sctlr |=3D (1 << 13); } @@ -2116,7 +2109,27 @@ static void arm_cpu_realizefn(DeviceState *dev, Erro= r **errp) if (cpu->core_count =3D=3D -1) { cpu->core_count =3D smp_cpus; } -#endif + + /* + * Provide a default cpu-id-to-MPIDR affinity; we don't support setting + * Aff2 or Aff3. This has already set by KVM and by some board models, + * which will have cleared our internal invalid bit. + */ + if (cpu->mpidr_el1 =3D=3D ARM64_AFFINITY_INVALID) { + assert(!kvm_enabled()); + assert(cs->cpu_index < 256 * ARM_DEFAULT_CPUS_PER_CLUSTER); + cpu->mpidr_el1 =3D arm_build_mp_affinity(cs->cpu_index, + ARM_DEFAULT_CPUS_PER_CLUSTE= R); + } +#endif /* !CONFIG_USER_ONLY */ + + /* Linux exposes M to userland, so still need to set it for user-only.= */ + if (arm_feature(env, ARM_FEATURE_V7MP)) { + cpu->mpidr_el1 |=3D (1u << 31); /* M */ + if (cpu->core_count =3D=3D 1) { + cpu->mpidr_el1 |=3D 1 << 30; /* U */ + } + } =20 if (tcg_enabled()) { int dcz_blocklen =3D 4 << cpu->dcz_blocksize; @@ -2176,10 +2189,47 @@ static ObjectClass *arm_cpu_class_by_name(const cha= r *cpu_model) return oc; } =20 +static void cpu_arm_set_mp_affinity(Object *obj, Visitor *v, const char *n= ame, + void *opaque, Error **errp) +{ + ARMCPU *cpu =3D ARM_CPU(obj); + CPUARMState *env =3D &cpu->env; + uint64_t value; + + if (!visit_type_uint64(v, name, &value, errp)) { + return; + } + + if (arm_feature(env, ARM_FEATURE_AARCH64)) { + value &=3D ARM64_AFFINITY_MASK; + } else { + value &=3D ARM32_AFFINITY_MASK; + } + if (cpu->mpidr_el1 =3D=3D ARM64_AFFINITY_INVALID) { + cpu->mpidr_el1 =3D value; + } else { + cpu->mpidr_el1 &=3D ~ARM64_AFFINITY_MASK; + cpu->mpidr_el1 |=3D value; + } +} + +static void cpu_arm_get_mp_affinity(Object *obj, Visitor *v, const char *n= ame, + void *opaque, Error **errp) +{ + ARMCPU *cpu =3D ARM_CPU(obj); + uint64_t value; + + /* + * Note that the arm64 mask is a superset of the arm32 mask, + * and we will have limited the value upon setting. + * Here we simply want to return the Aff[0-3] fields. + */ + value =3D cpu->mpidr_el1 & ARM64_AFFINITY_MASK; + visit_type_uint64(v, name, &value, errp); +} + static Property arm_cpu_properties[] =3D { DEFINE_PROP_UINT64("midr", ARMCPU, midr, 0), - DEFINE_PROP_UINT64("mp-affinity", ARMCPU, - mp_affinity, ARM64_AFFINITY_INVALID), DEFINE_PROP_INT32("node-id", ARMCPU, node_id, CPU_UNSET_NUMA_NODE_ID), DEFINE_PROP_INT32("core-count", ARMCPU, core_count, -1), DEFINE_PROP_END_OF_LIST() @@ -2244,6 +2294,10 @@ static void arm_cpu_class_init(ObjectClass *oc, void= *data) =20 device_class_set_props(dc, arm_cpu_properties); =20 + object_class_property_add(oc, "mp-affinity", "uint64", + cpu_arm_get_mp_affinity, + cpu_arm_set_mp_affinity, NULL, NULL); + resettable_class_set_parent_phases(rc, NULL, arm_cpu_reset_hold, NULL, &acc->parent_phases); =20 diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c index d566a815d3..7514065d5b 100644 --- a/target/arm/cpu_tcg.c +++ b/target/arm/cpu_tcg.c @@ -848,7 +848,6 @@ static void cortex_r5_initfn(Object *obj) cpu->isar.id_isar4 =3D 0x0010142; cpu->isar.id_isar5 =3D 0x0; cpu->isar.id_isar6 =3D 0x0; - cpu->mp_is_up =3D true; cpu->pmsav7_dregion =3D 16; cpu->isar.reset_pmcr_el0 =3D 0x41151800; define_arm_cp_regs(cpu, cortexr5_cp_reginfo); diff --git a/target/arm/helper.c b/target/arm/helper.c index bac2ea62c4..8f5097f995 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -4087,24 +4087,6 @@ static uint64_t midr_read(CPUARMState *env, const AR= MCPRegInfo *ri) return raw_read(env, ri); } =20 -static uint64_t mpidr_read_val(CPUARMState *env) -{ - ARMCPU *cpu =3D env_archcpu(env); - uint64_t mpidr =3D cpu->mp_affinity; - - if (arm_feature(env, ARM_FEATURE_V7MP)) { - mpidr |=3D (1U << 31); - /* Cores which are uniprocessor (non-coherent) - * but still implement the MP extensions set - * bit 30. (For instance, Cortex-R5). - */ - if (cpu->mp_is_up) { - mpidr |=3D (1u << 30); - } - } - return mpidr; -} - static uint64_t mpidr_read(CPUARMState *env, const ARMCPRegInfo *ri) { unsigned int cur_el =3D arm_current_el(env); @@ -4112,7 +4094,7 @@ static uint64_t mpidr_read(CPUARMState *env, const AR= MCPRegInfo *ri) if (arm_is_el2_enabled(env) && cur_el =3D=3D 1) { return env->cp15.vmpidr_el2; } - return mpidr_read_val(env); + return env_archcpu(env)->mpidr_el1; } =20 static const ARMCPRegInfo lpae_cp_reginfo[] =3D { @@ -7940,7 +7922,6 @@ void register_cp_regs_for_features(ARMCPU *cpu) if (arm_feature(env, ARM_FEATURE_EL2) || (arm_feature(env, ARM_FEATURE_EL3) && arm_feature(env, ARM_FEATURE_V8))) { - uint64_t vmpidr_def =3D mpidr_read_val(env); ARMCPRegInfo vpidr_regs[] =3D { { .name =3D "VPIDR", .state =3D ARM_CP_STATE_AA32, .cp =3D 15, .opc1 =3D 4, .crn =3D 0, .crm =3D 0, .opc2 =3D 0, @@ -7956,12 +7937,12 @@ void register_cp_regs_for_features(ARMCPU *cpu) { .name =3D "VMPIDR", .state =3D ARM_CP_STATE_AA32, .cp =3D 15, .opc1 =3D 4, .crn =3D 0, .crm =3D 0, .opc2 =3D 5, .access =3D PL2_RW, .accessfn =3D access_el3_aa32ns, - .resetvalue =3D vmpidr_def, + .resetvalue =3D cpu->mpidr_el1, .type =3D ARM_CP_ALIAS | ARM_CP_EL3_NO_EL2_C_NZ, .fieldoffset =3D offsetoflow32(CPUARMState, cp15.vmpidr_el2)= }, { .name =3D "VMPIDR_EL2", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 4, .crn =3D 0, .crm =3D 0, .opc2 =3D = 5, - .access =3D PL2_RW, .resetvalue =3D vmpidr_def, + .access =3D PL2_RW, .resetvalue =3D cpu->mpidr_el1, .type =3D ARM_CP_EL3_NO_EL2_C_NZ, .fieldoffset =3D offsetof(CPUARMState, cp15.vmpidr_el2) }, }; diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index e0ba91f5c6..278a4b2ede 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -607,7 +607,7 @@ int hvf_arch_init_vcpu(CPUState *cpu) assert_hvf_ok(ret); =20 ret =3D hv_vcpu_set_sys_reg(cpu->hvf->fd, HV_SYS_REG_MPIDR_EL1, - arm_cpu->mp_affinity); + arm_cpu->mpidr_el1); assert_hvf_ok(ret); =20 ret =3D hv_vcpu_get_sys_reg(cpu->hvf->fd, HV_SYS_REG_ID_AA64PFR0_EL1, = &pfr); diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c index 1197253d12..2cdd7517b8 100644 --- a/target/arm/kvm64.c +++ b/target/arm/kvm64.c @@ -914,11 +914,11 @@ int kvm_arch_init_vcpu(CPUState *cs) * Currently KVM has its own idea about MPIDR assignment, so we * override our defaults with what we get from KVM. */ - ret =3D kvm_get_one_reg(cs, ARM64_SYS_REG(ARM_CPU_ID_MPIDR), &mpidr); + ret =3D kvm_get_one_reg(cs, ARM64_SYS_REG(ARM_CPU_ID_MPIDR), + &cpu->mpidr_el1); if (ret) { return ret; } - cpu->mp_affinity =3D mpidr & ARM64_AFFINITY_MASK; =20 kvm_arm_init_debug(cs); =20 --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770030; cv=none; d=zohomail.com; s=zohoarc; b=Ks3j9gAG/+tGP+bAZ/SZKv0Hi2YBY1xB95pp6OAblvG5jimd+bm6MRBHxJF3u0r7Yzff1MCvDnTIViCLTnf58AD3oghhTxAakEFQKctZ3/Kim3DSQbY9ay7uwPRoeG5APvbByDErpVagHKBg3JC4JGSuCwhNH0LBU6BM68On92c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770030; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Wyr5V1dWDMqzJtGPzngC+jk55ZVA++3QMCuRXKZqttA=; b=H9sSNEKwryrPiQNyHLs6nVnegxhR5YQVA7kxiEfeJyp5P7FDdiJIcZdyHQSiZ/zxge3N2YmXUDD22Ct3MCOTVo5QaEFR1fr078uCD5/cNfmytV/waDVHhcjrfIWbx4Al8lp/o5ME53tIDFc1fTitZNjj5Za8NyoKdZ8E03yPK/8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770030754673.5573622379687; Tue, 3 Jan 2023 10:20:30 -0800 (PST) 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) 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) 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-Google-Smtp-Source: AMrXdXv3RHCHyU+PHEBzmgMN7e8Wp+p+pFM/qgbiZChizeWY1vjJ28HXKrTpxy34WKCwUb2s342B1Q== 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) 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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770032985100003 Content-Type: text/plain; charset="utf-8" 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; =20 + /* Coprocessor information */ + GHashTable *cp_regs; + /* 'compatible' string for this CPU for Linux device trees */ const char *dtb_compatible; =20 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 clu= stersz) return (Aff1 << ARM_AFF1_SHIFT) | Aff0; } =20 +static void copy_cp_regs_1(gpointer key, gpointer value, gpointer user) +{ + GHashTable *new_table =3D user; + ARMCPRegInfo *new_reg =3D g_memdup(value, sizeof(ARMCPRegInfo)); + bool ok =3D g_hash_table_insert(new_table, key, new_reg); + g_assert(ok); +} + +static GHashTable *copy_cp_regs(GHashTable *cp_regs) +{ + GHashTable *ret =3D g_hash_table_new_full(g_direct_hash, g_direct_equa= l, + 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 =3D ARM_CPU(obj); ARMCPUClass *acc =3D ARM_CPU_GET_CLASS(cpu); =20 cpu_set_cpustate_pointers(cpu); - cpu->cp_regs =3D g_hash_table_new_full(g_direct_hash, g_direct_equal, - NULL, g_free); =20 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 =3D acc->gic_pribits; cpu->kvm_target =3D acc->kvm_target; =20 + cpu->cp_regs =3D 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 =3D data; =20 acc->info =3D info; + acc->cp_regs =3D g_hash_table_new_full(g_direct_hash, g_direct_equal, + NULL, g_free); if (info->class_init) { info->class_init(acc); } --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770238; cv=none; d=zohomail.com; s=zohoarc; b=nsRZW1+DDi7qOHKHJ1+TDUSpjlb3nZB5fsagEUg624l2TkK5ye2mNOtECrxYHIMxaoFPbCGMey7cKDYHfnDOTIsV6rnTUU4S35ue0WlCfdQpztnHguOddpXDrU35GoQA1JA2vYQBqfm3HtNcY7lM48qzUwDVJRWQVLtOr2+5edU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770238; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=ovrzlFU5k82ZgCppHjlpfiJtVNxGU+QnnGdphNskZzQ=; b=AkTMGfO0Uh4tb6ILpZf4eIT/IxuP08m4ecxSH2RpvbfHhL0Urd/5ZTmyRqh65CAcclrmez+yQE00T78rfgkFNQLituLS4k+bTrn64fsCSkdDZQo8ND7dpMTZtAGwoHOpqnWkLYOhz9pbiMv2G9Y/cmgnktKtU6TCNHpq1SelLPY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770238412911.3350777532795; Tue, 3 Jan 2023 10:23:58 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrc-0000Bb-Cc; Tue, 03 Jan 2023 13:18:16 -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 1pClr8-0008Lc-Oz for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:49 -0500 Received: from mail-qt1-x831.google.com ([2607:f8b0:4864:20::831]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClr6-0005Fq-Sm for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:46 -0500 Received: by mail-qt1-x831.google.com with SMTP id bp44so22549670qtb.0 for ; Tue, 03 Jan 2023 10:17:43 -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.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:42 -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=ovrzlFU5k82ZgCppHjlpfiJtVNxGU+QnnGdphNskZzQ=; b=NX0fx278JDrgNVIG7ZrjCXhyYNuWS7NQjjJYOvJgqMtjeV2JCPJuZ/hJCIHpeDBwhD HjArKLZ6VTnsL573Vbunv82OPpqjR93TIyVxzXkYoWsweKiffTLWOb/xWzgVKj0VpPex kpdHCsLp5/VVlPL4/HEgwQfCrDUwf9HNK0boKMP04soTKI8f/MIJLqK9zpgFhkRs91tk W10FYyXpTW1f5l0LWXAl1n9DpMFJAXjcNGU73vJODJjezq00wA1JjcixL9kjloH5WbvF hib2TSvIz0sRa8RSI6vofBAi1YVQby/mTtRnOIVBHrY7HpR+lxqRzUV+jm1JK2RwC41b QCMw== 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=ovrzlFU5k82ZgCppHjlpfiJtVNxGU+QnnGdphNskZzQ=; b=xd6xLtgCNYXjYLDAZ/5E6AFN9ANuPXeTtiSccE4YP3qW3wXQJy0LlM1N/M3N0YMkk/ j4aHAM+aRP7BFAg491ve7mlTDlmiwQEjJU0QPL2TI8FH9RB8X/mIP1oIhsWcmRUcGMOj aCl6ql2d/5aPLS7CNS+bLAIzyBq40ukG9gF2Ixab6J+19RIiV6Oe4unTpb4KtTM+KwZ+ ekRdHuh/eMdaecsrEoWnwhZ6vvLm21Te2ZDY22Jh4V9T44qbdmyv1mXl8rygnzLxQD8W iISzpxmV4wYYkwPgZTfYO1WKEWS9ZMWT16xJj46orC8NUujBEO3qLAjpksC0nCzh0XFU 5sOA== X-Gm-Message-State: AFqh2kpBsyTeq7+3ICFgdkqovDLkLnHYsp9IJnc4/T9jTB7tphNaEtyF BvZKw4vaPn2pMIxzXP4p1J5RuMuKPFBWQlv9Ygw= X-Google-Smtp-Source: AMrXdXtbTghI6U/y+yxD5gLvIUnReaPRICy5HE/KObfyOJCqAUnZLuh1A59546GHiyltDHUziGm4CA== X-Received: by 2002:ac8:4b4c:0:b0:3a6:58fd:4e5e with SMTP id e12-20020ac84b4c000000b003a658fd4e5emr62796257qts.24.1672769863124; Tue, 03 Jan 2023 10:17:43 -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 18/40] target/arm: Create cpreg definition functions with GHashTable arg Date: Tue, 3 Jan 2023 10:16:24 -0800 Message-Id: <20230103181646.55711-19-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::831; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x831.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770240945100005 Content-Type: text/plain; charset="utf-8" This will allow registration of cpregs at the class level. Signed-off-by: Richard Henderson --- target/arm/cpregs.h | 33 +++++++++++++++++++++++++++---- target/arm/helper.c | 47 +++++++++++++++++++++++++-------------------- 2 files changed, 55 insertions(+), 25 deletions(-) diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h index 7e78c2c05c..11926c643e 100644 --- a/target/arm/cpregs.h +++ b/target/arm/cpregs.h @@ -381,16 +381,33 @@ struct ARMCPRegInfo { #define CPREG_FIELD64(env, ri) \ (*(uint64_t *)((char *)(env) + (ri)->fieldoffset)) =20 -void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, const ARMCPRegInfo *re= g, - void *opaque); +void define_one_arm_cp_reg_with_table(GHashTable *cp_regs, uint64_t featur= es, + const ARMCPRegInfo *reg, void *opaqu= e); + +void define_arm_cp_regs_with_table(GHashTable *cp_regs, uint64_t features, + const ARMCPRegInfo *regs, + void *opaque, size_t len); + +static inline void +define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, const ARMCPRegInfo *reg, + void *opaque) +{ + define_one_arm_cp_reg_with_table(cpu->cp_regs, cpu->env.features, + reg, opaque); +} =20 static inline void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *= regs) { define_one_arm_cp_reg_with_opaque(cpu, regs, NULL); } =20 -void define_arm_cp_regs_with_opaque_len(ARMCPU *cpu, const ARMCPRegInfo *r= egs, - void *opaque, size_t len); +static inline void +define_arm_cp_regs_with_opaque_len(ARMCPU *cpu, const ARMCPRegInfo *regs, + void *opaque, size_t len) +{ + define_arm_cp_regs_with_table(cpu->cp_regs, cpu->env.features, + regs, opaque, len); +} =20 #define define_arm_cp_regs_with_opaque(CPU, REGS, OPAQUE) \ do { \ @@ -402,6 +419,14 @@ void define_arm_cp_regs_with_opaque_len(ARMCPU *cpu, c= onst ARMCPRegInfo *regs, #define define_arm_cp_regs(CPU, REGS) \ define_arm_cp_regs_with_opaque(CPU, REGS, NULL) =20 +#define define_arm_cp_regs_with_class(ACC, REGS, OPAQUE) \ + do { \ + QEMU_BUILD_BUG_ON(ARRAY_SIZE(REGS) =3D=3D 0); = \ + ARMCPUClass *acc_ =3D (ACC); \ + define_arm_cp_regs_with_table(acc_->cp_regs, acc_->features, \ + REGS, OPAQUE, ARRAY_SIZE(REGS)); \ + } while (0) + const ARMCPRegInfo *get_arm_cp_reginfo(GHashTable *cpregs, uint32_t encode= d_cp); =20 /* diff --git a/target/arm/helper.c b/target/arm/helper.c index 8f5097f995..43756e130a 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -8527,13 +8527,13 @@ CpuDefinitionInfoList *qmp_query_cpu_definitions(Er= ror **errp) * Private utility function for define_one_arm_cp_reg_with_opaque(): * add a single reginfo struct to the hash table. */ -static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, +static void add_cpreg_to_hashtable(GHashTable *cp_regs, uint64_t features, + const ARMCPRegInfo *r, void *opaque, CPState state, CPSecureState secstate, int crm, int opc1, int opc2, const char *name) { - CPUARMState *env =3D &cpu->env; uint32_t key; ARMCPRegInfo *r2; bool is64 =3D r->type & ARM_CP_64BIT; @@ -8541,6 +8541,7 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const= ARMCPRegInfo *r, int cp =3D r->cp; size_t name_len; bool make_const; + bool have_el2; =20 switch (state) { case ARM_CP_STATE_AA32: @@ -8569,7 +8570,7 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const= ARMCPRegInfo *r, =20 /* Overriding of an existing definition must be explicitly requested. = */ if (!(r->type & ARM_CP_OVERRIDE)) { - const ARMCPRegInfo *oldreg =3D get_arm_cp_reginfo(cpu->cp_regs, ke= y); + const ARMCPRegInfo *oldreg =3D get_arm_cp_reginfo(cp_regs, key); if (oldreg) { assert(oldreg->type & ARM_CP_OVERRIDE); } @@ -8581,21 +8582,21 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, con= st ARMCPRegInfo *r, * feature into the same ARMCPRegInfo array and define them all at onc= e. */ make_const =3D false; - if (arm_feature(env, ARM_FEATURE_EL3)) { + have_el2 =3D features & (1ull << ARM_FEATURE_EL2); + if (features & (1ull << ARM_FEATURE_EL3)) { /* * An EL2 register without EL2 but with EL3 is (usually) RES0. * See rule RJFFP in section D1.1.3 of DDI0487H.a. */ int min_el =3D ctz32(r->access) / 2; - if (min_el =3D=3D 2 && !arm_feature(env, ARM_FEATURE_EL2)) { + if (min_el =3D=3D 2 && !have_el2) { if (r->type & ARM_CP_EL3_NO_EL2_UNDEF) { return; } make_const =3D !(r->type & ARM_CP_EL3_NO_EL2_KEEP); } } else { - CPAccessRights max_el =3D (arm_feature(env, ARM_FEATURE_EL2) - ? PL2_RW : PL1_RW); + CPAccessRights max_el =3D have_el2 ? PL2_RW : PL1_RW; if ((r->access & max_el) =3D=3D 0) { return; } @@ -8677,7 +8678,7 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const= ARMCPRegInfo *r, * that separate 32 and 64-bit definitions are provided. */ if ((r->state =3D=3D ARM_CP_STATE_BOTH && ns) || - (arm_feature(env, ARM_FEATURE_V8) && !ns)) { + ((features & (1ull << ARM_FEATURE_V8)) && !ns)) { r2->type |=3D ARM_CP_ALIAS; } } else if ((secstate !=3D r->secure) && !ns) { @@ -8720,12 +8721,11 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, con= st ARMCPRegInfo *r, assert(!raw_accessors_invalid(r2)); } =20 - g_hash_table_insert(cpu->cp_regs, (gpointer)(uintptr_t)key, r2); + g_hash_table_insert(cp_regs, (gpointer)(uintptr_t)key, r2); } =20 - -void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, - const ARMCPRegInfo *r, void *opaque) +void define_one_arm_cp_reg_with_table(GHashTable *cp_regs, uint64_t featur= es, + const ARMCPRegInfo *r, void *opaque) { /* Define implementations of coprocessor registers. * We store these in a hashtable because typically @@ -8781,8 +8781,8 @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, } /* fall through */ case ARM_CP_STATE_AA32: - if (arm_feature(&cpu->env, ARM_FEATURE_V8) && - !arm_feature(&cpu->env, ARM_FEATURE_M)) { + if ((features & (1ull << ARM_FEATURE_V8)) && + !(features & (1ull << ARM_FEATURE_M))) { assert(r->cp >=3D 14 && r->cp <=3D 15); } else { assert(r->cp < 8 || (r->cp >=3D 14 && r->cp <=3D 15)); @@ -8869,17 +8869,20 @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, switch (r->secure) { case ARM_CP_SECSTATE_S: case ARM_CP_SECSTATE_NS: - add_cpreg_to_hashtable(cpu, r, opaque, state, + add_cpreg_to_hashtable(cp_regs, features, r, + opaque, state, r->secure, crm, opc1, o= pc2, r->name); break; case ARM_CP_SECSTATE_BOTH: name =3D g_strdup_printf("%s_S", r->name); - add_cpreg_to_hashtable(cpu, r, opaque, state, + add_cpreg_to_hashtable(cp_regs, features, r, + opaque, state, ARM_CP_SECSTATE_S, crm, opc1, opc2, name); g_free(name); - add_cpreg_to_hashtable(cpu, r, opaque, state, + add_cpreg_to_hashtable(cp_regs, features, r, + opaque, state, ARM_CP_SECSTATE_NS, crm, opc1, opc2, r->nam= e); break; @@ -8889,7 +8892,8 @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, } else { /* AArch64 registers get mapped to non-secure inst= ance * of AArch32 */ - add_cpreg_to_hashtable(cpu, r, opaque, state, + add_cpreg_to_hashtable(cp_regs, features, r, + opaque, state, ARM_CP_SECSTATE_NS, crm, opc1, opc2, r->name); } @@ -8900,12 +8904,13 @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, } =20 /* Define a whole list of registers */ -void define_arm_cp_regs_with_opaque_len(ARMCPU *cpu, const ARMCPRegInfo *r= egs, - void *opaque, size_t len) +void define_arm_cp_regs_with_table(GHashTable *cp_regs, uint64_t features, + const ARMCPRegInfo *regs, + void *opaque, size_t len) { size_t i; for (i =3D 0; i < len; ++i) { - define_one_arm_cp_reg_with_opaque(cpu, regs + i, opaque); + define_one_arm_cp_reg_with_table(cp_regs, features, regs + i, opaq= ue); } } =20 --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770096; cv=none; d=zohomail.com; s=zohoarc; b=mfScWntRm1Xnr3aq42+cjxlbe7VBp+fkkkr4yej2T9bQs3YrqZvcxUgRJcbpTU1S3IQOAC4tUUIaPwuXBhlQVMAwcsBQKMpPHPtf4pW2mMucA9Mq7abD+2GbF32ogOe98O8+oV4EXjTNgDdu80sdo/QO0Kv+3PmMXEr51LSNuEI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770096; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=zAFkjIGv2XqewT6+4Aqot8thaYlSpZ+Y95cRcOD0ZRc=; b=JNE+QpB+/TRZ028BsVql9XdJpzosGA30CIKj9S8sDmEzz3WfnV19YxEIvTTwwbmHmjaruKwzMkscnZZcjc2Rx7G/3v+7ewCPG2pwqcoNfA32dq4nC3PQP5XfYR0pRfU/3QKkJrNNJaDnKt0ua7ABDQhmelO5ufmUdlhyFWK27N0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167277009671012.02170897801011; Tue, 3 Jan 2023 10:21:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrg-0000KC-5B; 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 1pClrE-0008MA-MH for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:53 -0500 Received: from mail-qt1-x836.google.com ([2607:f8b0:4864:20::836]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClr9-0005GE-QX for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:52 -0500 Received: by mail-qt1-x836.google.com with SMTP id z12so25178823qtv.5 for ; Tue, 03 Jan 2023 10:17:47 -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.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:46 -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=zAFkjIGv2XqewT6+4Aqot8thaYlSpZ+Y95cRcOD0ZRc=; b=HZNZBFb2d2NqKcpaVWtnHKnPjKe4ViTBG/fLWByQYc/LLvyPZWu81JCAKnrvh9E0Mt RYFIXBdjGk5pqLiTZLNx2qd8Z1pZajDo2V1gRNJPHYilwE3/Mwan6XCJNPMqFjnwQI2L 4dIYcc65GXBFepVTCwxgC45GjsNDxBudCT1GK6lQsljeTGoEkLfQcaPWWxVxRvt0knfr 8xf7HKlJswpGPToohT85zQa/lVJsZ3DpHBUwuGBNxKgBizlk6Xq7figowGnUtKbn0ZGW L0wxjxnbmcg6QIQ51JZZP5qK9vSbPRf3I52Olnw2CZ+pzJ1Qz/9uMkvQEYaryMcjLJjj 7UWg== 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=zAFkjIGv2XqewT6+4Aqot8thaYlSpZ+Y95cRcOD0ZRc=; b=N84c3nBr708Iuo2sv+5Z2Sdnrp5gy1C3XPyP+hrLoM4oYeefVRnxwgx1XaoX7efrvB kGB6i/H3rIpqnRIs3+Z9zIDnGCu41fUsrH5QWWGykKkewWmkchYAHEb2FCk72hiiiFcC Tu5bY69ggTOt8fOdph+qfjM0VrXfTQLe5MQu5UuY5VBSL6u8cSkL86GbfNvrTgtnELX4 egiKEKl3/oSFXWFDOlhn0il4y8JXoOXEWTcD0dErLmZ/Xl3BADZ2edyRirlwyR48ypQc qWOTluuwApzdTGNdKZv9DL2aUXt8FAuDIqBAoj4LWn5mypN7PfFbAJ5Yx/8bJqBltf/T ZPxw== X-Gm-Message-State: AFqh2kr4is57J/SNIkDpDQKblBsdqFbxQt0BXlz4UizO9rjUZeYr4wYC KWsqpbIh02uyt4ipsXgnbRB3GHQUF/5hsgA7xLQ= X-Google-Smtp-Source: AMrXdXvRYR9a9N4OUMqmMM+aVfujD/fXjWhE8JRhkkGRMon2wvjOf6rsu4ANua43QOY4SsRrNy+FTA== X-Received: by 2002:ac8:6a07:0:b0:39c:e105:6a14 with SMTP id t7-20020ac86a07000000b0039ce1056a14mr62230224qtr.26.1672769866562; Tue, 03 Jan 2023 10:17:46 -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 19/40] target/arm: Move most cpu initialization to the class Date: Tue, 3 Jan 2023 10:16:25 -0800 Message-Id: <20230103181646.55711-20-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::836; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x836.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770097390100001 Content-Type: text/plain; charset="utf-8" Quite a lot of the cpu definition is constant, and can be initialized once with the type, rather than for each object instance. For now, leave the "host" cpu with the object init. Note that the "max" class (and even a converted "host") must be delayed until accellerator init, which itself is delayed until after board init, which already creates all of the types. Thus we invent our own hook. Signed-off-by: Richard Henderson --- target/arm/cpu-qom.h | 3 +- target/arm/internals.h | 6 +- target/arm/cpu.c | 23 +- target/arm/cpu64.c | 227 +++++++++---------- target/arm/cpu_tcg.c | 496 ++++++++++++++++++----------------------- 5 files changed, 355 insertions(+), 400 deletions(-) diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h index 36d7fa9779..6b113d7fe6 100644 --- a/target/arm/cpu-qom.h +++ b/target/arm/cpu-qom.h @@ -35,8 +35,9 @@ OBJECT_DECLARE_CPU_TYPE(ARMCPU, ARMCPUClass, ARM_CPU) =20 typedef struct ARMCPUInfo { const char *name; - void (*initfn)(Object *obj); + void (*object_init)(Object *obj); void (*class_init)(ARMCPUClass *acc); + bool (*class_late_init)(ARMCPUClass *acc, Error **errp); } ARMCPUInfo; =20 void arm_cpu_register_parent(const ARMCPUInfo *info, const char *parent); diff --git a/target/arm/internals.h b/target/arm/internals.h index 161e42d50f..3feed370e7 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -1347,14 +1347,14 @@ void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **err= p); #endif =20 #ifdef CONFIG_USER_ONLY -static inline void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) { } +static inline void define_cortex_a72_a57_a53_cp_reginfo(ARMCPUClass *acc) = { } #else -void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu); +void define_cortex_a72_a57_a53_cp_reginfo(ARMCPUClass *acc); #endif =20 bool el_is_in_host(CPUARMState *env, int el); =20 -void aa32_max_features(ARMCPU *cpu); +void aa32_max_features(ARMCPUClass *acc); int exception_target_el(CPUARMState *env); bool arm_singlestep_active(CPUARMState *env); bool arm_generate_debug_exceptions(CPUARMState *env); diff --git a/target/arm/cpu.c b/target/arm/cpu.c index da58f1fae7..c58029fb4a 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -2351,23 +2351,35 @@ static void arm_cpu_class_init(ObjectClass *oc, voi= d *data) static void arm_cpu_leaf_class_init(ObjectClass *oc, void *data) { ARMCPUClass *acc =3D ARM_CPU_CLASS(oc); - const ARMCPUInfo *info =3D data; =20 - acc->info =3D info; acc->cp_regs =3D g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free); - if (info->class_init) { - info->class_init(acc); + + acc->info =3D data; + if (acc->info->class_init) { + acc->info->class_init(acc); } } =20 +static bool arm_cpu_class_late_init(ObjectClass *oc, Error **errp) +{ + ARMCPUClass *acc =3D ARM_CPU_CLASS(oc); + + if (acc->info->class_late_init) { + if (!acc->info->class_late_init(acc, errp)) { + return false; + } + } + return true; +} + void arm_cpu_register_parent(const ARMCPUInfo *info, const char *parent) { TypeInfo type_info =3D { .parent =3D parent, .instance_size =3D sizeof(ARMCPU), .instance_align =3D __alignof__(ARMCPU), - .instance_init =3D info->initfn, + .instance_init =3D info->object_init, .class_size =3D sizeof(ARMCPUClass), .class_init =3D arm_cpu_leaf_class_init, .class_data =3D (void *)info, @@ -2389,6 +2401,7 @@ static const TypeInfo arm_cpu_type_info =3D { .abstract =3D true, .class_size =3D sizeof(ARMCPUClass), .class_init =3D arm_cpu_class_init, + .class_late_init =3D arm_cpu_class_late_init, }; =20 static void arm_cpu_register_types(void) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 1d3aff868d..28b5a07244 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -36,19 +36,17 @@ #include "hw/qdev-properties.h" #include "internals.h" =20 -static void aarch64_a35_initfn(Object *obj) +static void aarch64_a35_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "arm,cortex-a35"; - set_feature(&cpu->env, ARM_FEATURE_V8); - set_feature(&cpu->env, ARM_FEATURE_NEON); - set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); - set_feature(&cpu->env, ARM_FEATURE_AARCH64); - set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); - set_feature(&cpu->env, ARM_FEATURE_EL2); - set_feature(&cpu->env, ARM_FEATURE_EL3); - set_feature(&cpu->env, ARM_FEATURE_PMU); + set_class_feature(cpu, ARM_FEATURE_V8); + set_class_feature(cpu, ARM_FEATURE_NEON); + set_class_feature(cpu, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(cpu, ARM_FEATURE_AARCH64); + set_class_feature(cpu, ARM_FEATURE_CBAR_RO); + set_class_feature(cpu, ARM_FEATURE_EL2); + set_class_feature(cpu, ARM_FEATURE_EL3); + set_class_feature(cpu, ARM_FEATURE_PMU); =20 /* From B2.2 AArch64 identification registers. */ cpu->midr =3D 0x411fd040; @@ -678,19 +676,17 @@ void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp) cpu->isar.id_aa64mmfr0 =3D t; } =20 -static void aarch64_a57_initfn(Object *obj) +static void aarch64_a57_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "arm,cortex-a57"; - set_feature(&cpu->env, ARM_FEATURE_V8); - set_feature(&cpu->env, ARM_FEATURE_NEON); - set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); - set_feature(&cpu->env, ARM_FEATURE_AARCH64); - set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); - set_feature(&cpu->env, ARM_FEATURE_EL2); - set_feature(&cpu->env, ARM_FEATURE_EL3); - set_feature(&cpu->env, ARM_FEATURE_PMU); + set_class_feature(cpu, ARM_FEATURE_V8); + set_class_feature(cpu, ARM_FEATURE_NEON); + set_class_feature(cpu, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(cpu, ARM_FEATURE_AARCH64); + set_class_feature(cpu, ARM_FEATURE_CBAR_RO); + set_class_feature(cpu, ARM_FEATURE_EL2); + set_class_feature(cpu, ARM_FEATURE_EL3); + set_class_feature(cpu, ARM_FEATURE_PMU); cpu->kvm_target =3D QEMU_KVM_ARM_TARGET_CORTEX_A57; cpu->midr =3D 0x411fd070; cpu->revidr =3D 0x00000000; @@ -735,19 +731,17 @@ static void aarch64_a57_initfn(Object *obj) define_cortex_a72_a57_a53_cp_reginfo(cpu); } =20 -static void aarch64_a53_initfn(Object *obj) +static void aarch64_a53_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "arm,cortex-a53"; - set_feature(&cpu->env, ARM_FEATURE_V8); - set_feature(&cpu->env, ARM_FEATURE_NEON); - set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); - set_feature(&cpu->env, ARM_FEATURE_AARCH64); - set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); - set_feature(&cpu->env, ARM_FEATURE_EL2); - set_feature(&cpu->env, ARM_FEATURE_EL3); - set_feature(&cpu->env, ARM_FEATURE_PMU); + set_class_feature(cpu, ARM_FEATURE_V8); + set_class_feature(cpu, ARM_FEATURE_NEON); + set_class_feature(cpu, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(cpu, ARM_FEATURE_AARCH64); + set_class_feature(cpu, ARM_FEATURE_CBAR_RO); + set_class_feature(cpu, ARM_FEATURE_EL2); + set_class_feature(cpu, ARM_FEATURE_EL3); + set_class_feature(cpu, ARM_FEATURE_PMU); cpu->kvm_target =3D QEMU_KVM_ARM_TARGET_CORTEX_A53; cpu->midr =3D 0x410fd034; cpu->revidr =3D 0x00000000; @@ -792,19 +786,17 @@ static void aarch64_a53_initfn(Object *obj) define_cortex_a72_a57_a53_cp_reginfo(cpu); } =20 -static void aarch64_a55_initfn(Object *obj) +static void aarch64_a55_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "arm,cortex-a55"; - set_feature(&cpu->env, ARM_FEATURE_V8); - set_feature(&cpu->env, ARM_FEATURE_NEON); - set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); - set_feature(&cpu->env, ARM_FEATURE_AARCH64); - set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); - set_feature(&cpu->env, ARM_FEATURE_EL2); - set_feature(&cpu->env, ARM_FEATURE_EL3); - set_feature(&cpu->env, ARM_FEATURE_PMU); + set_class_feature(cpu, ARM_FEATURE_V8); + set_class_feature(cpu, ARM_FEATURE_NEON); + set_class_feature(cpu, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(cpu, ARM_FEATURE_AARCH64); + set_class_feature(cpu, ARM_FEATURE_CBAR_RO); + set_class_feature(cpu, ARM_FEATURE_EL2); + set_class_feature(cpu, ARM_FEATURE_EL3); + set_class_feature(cpu, ARM_FEATURE_PMU); =20 /* Ordered by B2.4 AArch64 registers by functional group */ cpu->clidr =3D 0x82000023; @@ -860,19 +852,17 @@ static void aarch64_a55_initfn(Object *obj) cpu->isar.reset_pmcr_el0 =3D 0x410b3000; } =20 -static void aarch64_a72_initfn(Object *obj) +static void aarch64_a72_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "arm,cortex-a72"; - set_feature(&cpu->env, ARM_FEATURE_V8); - set_feature(&cpu->env, ARM_FEATURE_NEON); - set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); - set_feature(&cpu->env, ARM_FEATURE_AARCH64); - set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); - set_feature(&cpu->env, ARM_FEATURE_EL2); - set_feature(&cpu->env, ARM_FEATURE_EL3); - set_feature(&cpu->env, ARM_FEATURE_PMU); + set_class_feature(cpu, ARM_FEATURE_V8); + set_class_feature(cpu, ARM_FEATURE_NEON); + set_class_feature(cpu, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(cpu, ARM_FEATURE_AARCH64); + set_class_feature(cpu, ARM_FEATURE_CBAR_RO); + set_class_feature(cpu, ARM_FEATURE_EL2); + set_class_feature(cpu, ARM_FEATURE_EL3); + set_class_feature(cpu, ARM_FEATURE_PMU); cpu->midr =3D 0x410fd083; cpu->revidr =3D 0x00000000; cpu->reset_fpsid =3D 0x41034080; @@ -915,19 +905,17 @@ static void aarch64_a72_initfn(Object *obj) define_cortex_a72_a57_a53_cp_reginfo(cpu); } =20 -static void aarch64_a76_initfn(Object *obj) +static void aarch64_a76_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "arm,cortex-a76"; - set_feature(&cpu->env, ARM_FEATURE_V8); - set_feature(&cpu->env, ARM_FEATURE_NEON); - set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); - set_feature(&cpu->env, ARM_FEATURE_AARCH64); - set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); - set_feature(&cpu->env, ARM_FEATURE_EL2); - set_feature(&cpu->env, ARM_FEATURE_EL3); - set_feature(&cpu->env, ARM_FEATURE_PMU); + set_class_feature(cpu, ARM_FEATURE_V8); + set_class_feature(cpu, ARM_FEATURE_NEON); + set_class_feature(cpu, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(cpu, ARM_FEATURE_AARCH64); + set_class_feature(cpu, ARM_FEATURE_CBAR_RO); + set_class_feature(cpu, ARM_FEATURE_EL2); + set_class_feature(cpu, ARM_FEATURE_EL3); + set_class_feature(cpu, ARM_FEATURE_PMU); =20 /* Ordered by B2.4 AArch64 registers by functional group */ cpu->clidr =3D 0x82000023; @@ -984,18 +972,16 @@ static void aarch64_a76_initfn(Object *obj) cpu->isar.reset_pmcr_el0 =3D 0x410b3000; } =20 -static void aarch64_a64fx_initfn(Object *obj) +static void aarch64_a64fx_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "arm,a64fx"; - set_feature(&cpu->env, ARM_FEATURE_V8); - set_feature(&cpu->env, ARM_FEATURE_NEON); - set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); - set_feature(&cpu->env, ARM_FEATURE_AARCH64); - set_feature(&cpu->env, ARM_FEATURE_EL2); - set_feature(&cpu->env, ARM_FEATURE_EL3); - set_feature(&cpu->env, ARM_FEATURE_PMU); + set_class_feature(cpu, ARM_FEATURE_V8); + set_class_feature(cpu, ARM_FEATURE_NEON); + set_class_feature(cpu, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(cpu, ARM_FEATURE_AARCH64); + set_class_feature(cpu, ARM_FEATURE_EL2); + set_class_feature(cpu, ARM_FEATURE_EL3); + set_class_feature(cpu, ARM_FEATURE_PMU); cpu->midr =3D 0x461f0010; cpu->revidr =3D 0x00000000; cpu->ctr =3D 0x86668006; @@ -1021,31 +1007,33 @@ static void aarch64_a64fx_initfn(Object *obj) cpu->gic_vpribits =3D 5; cpu->gic_vprebits =3D 5; cpu->gic_pribits =3D 5; + cpu->isar.reset_pmcr_el0 =3D 0x46014040; + + /* TODO: Add A64FX specific HPC extension registers */ +} + +static void aarch64_a64fx_object_init(Object *obj) +{ + ARMCPU *cpu =3D ARM_CPU(obj); =20 /* The A64FX supports only 128, 256 and 512 bit vector lengths */ aarch64_add_sve_properties(obj); cpu->sve_vq.supported =3D (1 << 0) /* 128bit */ | (1 << 1) /* 256bit */ | (1 << 3); /* 512bit */ - - cpu->isar.reset_pmcr_el0 =3D 0x46014040; - - /* TODO: Add A64FX specific HPC extension registers */ } =20 -static void aarch64_neoverse_n1_initfn(Object *obj) +static void aarch64_neoverse_n1_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "arm,neoverse-n1"; - set_feature(&cpu->env, ARM_FEATURE_V8); - set_feature(&cpu->env, ARM_FEATURE_NEON); - set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); - set_feature(&cpu->env, ARM_FEATURE_AARCH64); - set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); - set_feature(&cpu->env, ARM_FEATURE_EL2); - set_feature(&cpu->env, ARM_FEATURE_EL3); - set_feature(&cpu->env, ARM_FEATURE_PMU); + set_class_feature(cpu, ARM_FEATURE_V8); + set_class_feature(cpu, ARM_FEATURE_NEON); + set_class_feature(cpu, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(cpu, ARM_FEATURE_AARCH64); + set_class_feature(cpu, ARM_FEATURE_CBAR_RO); + set_class_feature(cpu, ARM_FEATURE_EL2); + set_class_feature(cpu, ARM_FEATURE_EL3); + set_class_feature(cpu, ARM_FEATURE_PMU); =20 /* Ordered by B2.4 AArch64 registers by functional group */ cpu->clidr =3D 0x82000023; @@ -1102,7 +1090,7 @@ static void aarch64_neoverse_n1_initfn(Object *obj) cpu->isar.reset_pmcr_el0 =3D 0x410c3000; } =20 -static void aarch64_host_initfn(Object *obj) +static void aarch64_host_object_init(Object *obj) { #if defined(CONFIG_KVM) ARMCPU *cpu =3D ARM_CPU(obj); @@ -1120,26 +1108,24 @@ static void aarch64_host_initfn(Object *obj) #endif } =20 -/* -cpu max: if KVM is enabled, like -cpu host (best possible with this ho= st); - * otherwise, a CPU with as many features enabled as our emulation support= s. +/* + * -cpu max: if hardware acceleration is enabled, like -cpu host + * (best possible with this host); otherwise, a CPU with as many + * features enabled as TCG supports. * The version of '-cpu max' for qemu-system-arm is defined in cpu.c; - * this only needs to handle 64 bits. + * this version only needs to handle 64 bits. */ -static void aarch64_max_initfn(Object *obj) +static bool aarch64_max_class_late_init(ARMCPUClass *cpu, Error **errp) { - ARMCPU *cpu =3D ARM_CPU(obj); uint64_t t; uint32_t u; =20 if (kvm_enabled() || hvf_enabled()) { - /* With KVM or HVF, '-cpu max' is identical to '-cpu host' */ - aarch64_host_initfn(obj); - return; + return true; } =20 /* '-cpu max' for TCG: we currently do this as "A57 with extra things"= */ - - aarch64_a57_initfn(obj); + aarch64_a57_class_init(cpu); =20 /* * Reset MIDR so the guest doesn't mistake our 'max' CPU type for a re= al @@ -1296,6 +1282,18 @@ static void aarch64_max_initfn(Object *obj) cpu->ctr =3D 0x80038003; /* 32 byte I and D cacheline size, VIPT icach= e */ cpu->dcz_blocksize =3D 7; /* 512 bytes */ #endif + return true; +} + +static void aarch64_max_object_init(Object *obj) +{ + ARMCPU *cpu =3D ARM_CPU(obj); + + if (kvm_enabled() || hvf_enabled()) { + /* With KVM or HVF, '-cpu max' is identical to '-cpu host' */ + aarch64_host_object_init(obj); + return; + } =20 cpu->sve_vq.supported =3D MAKE_64BIT_MASK(0, ARM_MAX_VQ); cpu->sme_vq.supported =3D SVE_VQ_POW2_MAP; @@ -1309,17 +1307,22 @@ static void aarch64_max_initfn(Object *obj) } =20 static const ARMCPUInfo aarch64_cpus[] =3D { - { .name =3D "cortex-a35", .initfn =3D aarch64_a35_initfn }, - { .name =3D "cortex-a57", .initfn =3D aarch64_a57_initfn }, - { .name =3D "cortex-a53", .initfn =3D aarch64_a53_initfn }, - { .name =3D "cortex-a55", .initfn =3D aarch64_a55_initfn }, - { .name =3D "cortex-a72", .initfn =3D aarch64_a72_initfn }, - { .name =3D "cortex-a76", .initfn =3D aarch64_a76_initfn }, - { .name =3D "a64fx", .initfn =3D aarch64_a64fx_initfn }, - { .name =3D "neoverse-n1", .initfn =3D aarch64_neoverse_n1_init= fn }, - { .name =3D "max", .initfn =3D aarch64_max_initfn }, + { .name =3D "cortex-a35", .class_init =3D aarch64_a35_class_init }, + { .name =3D "cortex-a57", .class_init =3D aarch64_a57_class_init }, + { .name =3D "cortex-a53", .class_init =3D aarch64_a53_class_init }, + { .name =3D "cortex-a55", .class_init =3D aarch64_a55_class_init }, + { .name =3D "cortex-a72", .class_init =3D aarch64_a72_class_init }, + { .name =3D "cortex-a76", .class_init =3D aarch64_a76_class_init }, + { .name =3D "neoverse-n1", .class_init =3D aarch64_neoverse_n1_class_i= nit }, + { .name =3D "a64fx", + .class_init =3D aarch64_a64fx_class_init, + .object_init =3D aarch64_a64fx_object_init }, + { .name =3D "max", + .class_late_init =3D aarch64_max_class_late_init, + .object_init =3D aarch64_max_object_init }, #if defined(CONFIG_KVM) || defined(CONFIG_HVF) - { .name =3D "host", .initfn =3D aarch64_host_initfn }, + { .name =3D "host", + .object_init =3D aarch64_host_object_init }, #endif }; =20 diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c index 7514065d5b..f35b4a52b0 100644 --- a/target/arm/cpu_tcg.c +++ b/target/arm/cpu_tcg.c @@ -22,7 +22,7 @@ =20 =20 /* Share AArch32 -cpu max features with AArch64. */ -void aa32_max_features(ARMCPU *cpu) +void aa32_max_features(ARMCPUClass *cpu) { uint32_t t; =20 @@ -143,9 +143,9 @@ static const ARMCPRegInfo cortex_a72_a57_a53_cp_reginfo= [] =3D { .access =3D PL1_RW, .type =3D ARM_CP_CONST | ARM_CP_64BIT, .resetval= ue =3D 0 }, }; =20 -void define_cortex_a72_a57_a53_cp_reginfo(ARMCPU *cpu) +void define_cortex_a72_a57_a53_cp_reginfo(ARMCPUClass *acc) { - define_arm_cp_regs(cpu, cortex_a72_a57_a53_cp_reginfo); + define_arm_cp_regs_with_class(acc, cortex_a72_a57_a53_cp_reginfo, NULL= ); } #endif /* !CONFIG_USER_ONLY */ =20 @@ -178,14 +178,12 @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, = int interrupt_request) } #endif /* !CONFIG_USER_ONLY && CONFIG_TCG */ =20 -static void arm926_initfn(Object *obj) +static void arm926_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "arm,arm926"; - set_feature(&cpu->env, ARM_FEATURE_V5); - set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); - set_feature(&cpu->env, ARM_FEATURE_CACHE_TEST_CLEAN); + set_class_feature(cpu, ARM_FEATURE_V5); + set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); + set_class_feature(cpu, ARM_FEATURE_CACHE_TEST_CLEAN); cpu->midr =3D 0x41069265; cpu->reset_fpsid =3D 0x41011090; cpu->ctr =3D 0x1dd20d2; @@ -205,28 +203,32 @@ static void arm926_initfn(Object *obj) cpu->isar.mvfr0 =3D FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1); } =20 -static void arm946_initfn(Object *obj) +static void arm946_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "arm,arm946"; - set_feature(&cpu->env, ARM_FEATURE_V5); - set_feature(&cpu->env, ARM_FEATURE_PMSA); - set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); + set_class_feature(cpu, ARM_FEATURE_V5); + set_class_feature(cpu, ARM_FEATURE_PMSA); + set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); cpu->midr =3D 0x41059461; cpu->ctr =3D 0x0f004006; cpu->reset_sctlr =3D 0x00000078; } =20 -static void arm1026_initfn(Object *obj) +static void arm1026_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); + /* The 1026 had an IFAR at c6,c0,0,1 rather than the ARMv6 c6,c0,0,2 */ + static const ARMCPRegInfo ifar[1] =3D { + { .name =3D "IFAR", .cp =3D 15, .crn =3D 6, .crm =3D 0, .opc1 =3D = 0, .opc2 =3D 1, + .access =3D PL1_RW, + .fieldoffset =3D offsetof(CPUARMState, cp15.ifar_ns), + .resetvalue =3D 0 } + }; =20 cpu->dtb_compatible =3D "arm,arm1026"; - set_feature(&cpu->env, ARM_FEATURE_V5); - set_feature(&cpu->env, ARM_FEATURE_AUXCR); - set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); - set_feature(&cpu->env, ARM_FEATURE_CACHE_TEST_CLEAN); + set_class_feature(cpu, ARM_FEATURE_V5); + set_class_feature(cpu, ARM_FEATURE_AUXCR); + set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); + set_class_feature(cpu, ARM_FEATURE_CACHE_TEST_CLEAN); cpu->midr =3D 0x4106a262; cpu->reset_fpsid =3D 0x410110a0; cpu->ctr =3D 0x1dd20d2; @@ -246,21 +248,11 @@ static void arm1026_initfn(Object *obj) cpu->isar.mvfr0 =3D FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSP, 1); cpu->isar.mvfr0 =3D FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1); =20 - { - /* The 1026 had an IFAR at c6,c0,0,1 rather than the ARMv6 c6,c0,0= ,2 */ - ARMCPRegInfo ifar =3D { - .name =3D "IFAR", .cp =3D 15, .crn =3D 6, .crm =3D 0, .opc1 = =3D 0, .opc2 =3D 1, - .access =3D PL1_RW, - .fieldoffset =3D offsetof(CPUARMState, cp15.ifar_ns), - .resetvalue =3D 0 - }; - define_one_arm_cp_reg(cpu, &ifar); - } + define_arm_cp_regs_with_class(cpu, ifar, NULL); } =20 -static void arm1136_r2_initfn(Object *obj) +static void arm1136_r2_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); /* * What qemu calls "arm1136_r2" is actually the 1136 r0p2, ie an * older core than plain "arm1136". In particular this does not @@ -271,10 +263,10 @@ static void arm1136_r2_initfn(Object *obj) */ =20 cpu->dtb_compatible =3D "arm,arm1136"; - set_feature(&cpu->env, ARM_FEATURE_V6); - set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); - set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG); - set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS); + set_class_feature(cpu, ARM_FEATURE_V6); + set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); + set_class_feature(cpu, ARM_FEATURE_CACHE_DIRTY_REG); + set_class_feature(cpu, ARM_FEATURE_CACHE_BLOCK_OPS); cpu->midr =3D 0x4107b362; cpu->reset_fpsid =3D 0x410120b4; cpu->isar.mvfr0 =3D 0x11111111; @@ -296,16 +288,14 @@ static void arm1136_r2_initfn(Object *obj) cpu->reset_auxcr =3D 7; } =20 -static void arm1136_initfn(Object *obj) +static void arm1136_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "arm,arm1136"; - set_feature(&cpu->env, ARM_FEATURE_V6K); - set_feature(&cpu->env, ARM_FEATURE_V6); - set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); - set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG); - set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS); + set_class_feature(cpu, ARM_FEATURE_V6K); + set_class_feature(cpu, ARM_FEATURE_V6); + set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); + set_class_feature(cpu, ARM_FEATURE_CACHE_DIRTY_REG); + set_class_feature(cpu, ARM_FEATURE_CACHE_BLOCK_OPS); cpu->midr =3D 0x4117b363; cpu->reset_fpsid =3D 0x410120b4; cpu->isar.mvfr0 =3D 0x11111111; @@ -327,17 +317,15 @@ static void arm1136_initfn(Object *obj) cpu->reset_auxcr =3D 7; } =20 -static void arm1176_initfn(Object *obj) +static void arm1176_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "arm,arm1176"; - set_feature(&cpu->env, ARM_FEATURE_V6K); - set_feature(&cpu->env, ARM_FEATURE_VAPA); - set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); - set_feature(&cpu->env, ARM_FEATURE_CACHE_DIRTY_REG); - set_feature(&cpu->env, ARM_FEATURE_CACHE_BLOCK_OPS); - set_feature(&cpu->env, ARM_FEATURE_EL3); + set_class_feature(cpu, ARM_FEATURE_V6K); + set_class_feature(cpu, ARM_FEATURE_VAPA); + set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); + set_class_feature(cpu, ARM_FEATURE_CACHE_DIRTY_REG); + set_class_feature(cpu, ARM_FEATURE_CACHE_BLOCK_OPS); + set_class_feature(cpu, ARM_FEATURE_EL3); cpu->midr =3D 0x410fb767; cpu->reset_fpsid =3D 0x410120b5; cpu->isar.mvfr0 =3D 0x11111111; @@ -359,15 +347,13 @@ static void arm1176_initfn(Object *obj) cpu->reset_auxcr =3D 7; } =20 -static void arm11mpcore_initfn(Object *obj) +static void arm11mpcore_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "arm,arm11mpcore"; - set_feature(&cpu->env, ARM_FEATURE_V6K); - set_feature(&cpu->env, ARM_FEATURE_VAPA); - set_feature(&cpu->env, ARM_FEATURE_MPIDR); - set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); + set_class_feature(cpu, ARM_FEATURE_V6K); + set_class_feature(cpu, ARM_FEATURE_VAPA); + set_class_feature(cpu, ARM_FEATURE_MPIDR); + set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); cpu->midr =3D 0x410fb022; cpu->reset_fpsid =3D 0x410120b4; cpu->isar.mvfr0 =3D 0x11111111; @@ -395,16 +381,14 @@ static const ARMCPRegInfo cortexa8_cp_reginfo[] =3D { .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, }; =20 -static void cortex_a8_initfn(Object *obj) +static void cortex_a8_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "arm,cortex-a8"; - set_feature(&cpu->env, ARM_FEATURE_V7); - set_feature(&cpu->env, ARM_FEATURE_NEON); - set_feature(&cpu->env, ARM_FEATURE_THUMB2EE); - set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); - set_feature(&cpu->env, ARM_FEATURE_EL3); + set_class_feature(cpu, ARM_FEATURE_V7); + set_class_feature(cpu, ARM_FEATURE_NEON); + set_class_feature(cpu, ARM_FEATURE_THUMB2EE); + set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); + set_class_feature(cpu, ARM_FEATURE_EL3); cpu->midr =3D 0x410fc080; cpu->reset_fpsid =3D 0x410330c0; cpu->isar.mvfr0 =3D 0x11110222; @@ -431,7 +415,7 @@ static void cortex_a8_initfn(Object *obj) cpu->ccsidr[2] =3D 0xf0000000; /* No L2 icache. */ cpu->reset_auxcr =3D 2; cpu->isar.reset_pmcr_el0 =3D 0x41002000; - define_arm_cp_regs(cpu, cortexa8_cp_reginfo); + define_arm_cp_regs_with_class(cpu, cortexa8_cp_reginfo, NULL); } =20 static const ARMCPRegInfo cortexa9_cp_reginfo[] =3D { @@ -463,22 +447,20 @@ static const ARMCPRegInfo cortexa9_cp_reginfo[] =3D { .access =3D PL1_RW, .resetvalue =3D 0, .type =3D ARM_CP_CONST }, }; =20 -static void cortex_a9_initfn(Object *obj) +static void cortex_a9_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "arm,cortex-a9"; - set_feature(&cpu->env, ARM_FEATURE_V7); - set_feature(&cpu->env, ARM_FEATURE_NEON); - set_feature(&cpu->env, ARM_FEATURE_THUMB2EE); - set_feature(&cpu->env, ARM_FEATURE_EL3); + set_class_feature(cpu, ARM_FEATURE_V7); + set_class_feature(cpu, ARM_FEATURE_NEON); + set_class_feature(cpu, ARM_FEATURE_THUMB2EE); + set_class_feature(cpu, ARM_FEATURE_EL3); /* * Note that A9 supports the MP extensions even for * A9UP and single-core A9MP (which are both different * and valid configurations; we don't model A9UP). */ - set_feature(&cpu->env, ARM_FEATURE_V7MP); - set_feature(&cpu->env, ARM_FEATURE_CBAR); + set_class_feature(cpu, ARM_FEATURE_V7MP); + set_class_feature(cpu, ARM_FEATURE_CBAR); cpu->midr =3D 0x410fc090; cpu->reset_fpsid =3D 0x41033090; cpu->isar.mvfr0 =3D 0x11110222; @@ -503,7 +485,7 @@ static void cortex_a9_initfn(Object *obj) cpu->ccsidr[0] =3D 0xe00fe019; /* 16k L1 dcache. */ cpu->ccsidr[1] =3D 0x200fe019; /* 16k L1 icache. */ cpu->isar.reset_pmcr_el0 =3D 0x41093000; - define_arm_cp_regs(cpu, cortexa9_cp_reginfo); + define_arm_cp_regs_with_class(cpu, cortexa9_cp_reginfo, NULL); } =20 #ifndef CONFIG_USER_ONLY @@ -529,20 +511,18 @@ static const ARMCPRegInfo cortexa15_cp_reginfo[] =3D { .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, }; =20 -static void cortex_a7_initfn(Object *obj) +static void cortex_a7_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "arm,cortex-a7"; - set_feature(&cpu->env, ARM_FEATURE_V7VE); - set_feature(&cpu->env, ARM_FEATURE_NEON); - set_feature(&cpu->env, ARM_FEATURE_THUMB2EE); - set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); - set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); - set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); - set_feature(&cpu->env, ARM_FEATURE_EL2); - set_feature(&cpu->env, ARM_FEATURE_EL3); - set_feature(&cpu->env, ARM_FEATURE_PMU); + set_class_feature(cpu, ARM_FEATURE_V7VE); + set_class_feature(cpu, ARM_FEATURE_NEON); + set_class_feature(cpu, ARM_FEATURE_THUMB2EE); + set_class_feature(cpu, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); + set_class_feature(cpu, ARM_FEATURE_CBAR_RO); + set_class_feature(cpu, ARM_FEATURE_EL2); + set_class_feature(cpu, ARM_FEATURE_EL3); + set_class_feature(cpu, ARM_FEATURE_PMU); cpu->kvm_target =3D QEMU_KVM_ARM_TARGET_CORTEX_A7; cpu->midr =3D 0x410fc075; cpu->reset_fpsid =3D 0x41023075; @@ -575,23 +555,23 @@ static void cortex_a7_initfn(Object *obj) cpu->ccsidr[1] =3D 0x201fe00a; /* 32K L1 icache */ cpu->ccsidr[2] =3D 0x711fe07a; /* 4096K L2 unified cache */ cpu->isar.reset_pmcr_el0 =3D 0x41072000; - define_arm_cp_regs(cpu, cortexa15_cp_reginfo); /* Same as A15 */ + + /* Same as A15 */ + define_arm_cp_regs_with_class(cpu, cortexa15_cp_reginfo, NULL); } =20 -static void cortex_a15_initfn(Object *obj) +static void cortex_a15_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "arm,cortex-a15"; - set_feature(&cpu->env, ARM_FEATURE_V7VE); - set_feature(&cpu->env, ARM_FEATURE_NEON); - set_feature(&cpu->env, ARM_FEATURE_THUMB2EE); - set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); - set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); - set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); - set_feature(&cpu->env, ARM_FEATURE_EL2); - set_feature(&cpu->env, ARM_FEATURE_EL3); - set_feature(&cpu->env, ARM_FEATURE_PMU); + set_class_feature(cpu, ARM_FEATURE_V7VE); + set_class_feature(cpu, ARM_FEATURE_NEON); + set_class_feature(cpu, ARM_FEATURE_THUMB2EE); + set_class_feature(cpu, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); + set_class_feature(cpu, ARM_FEATURE_CBAR_RO); + set_class_feature(cpu, ARM_FEATURE_EL2); + set_class_feature(cpu, ARM_FEATURE_EL3); + set_class_feature(cpu, ARM_FEATURE_PMU); cpu->kvm_target =3D QEMU_KVM_ARM_TARGET_CORTEX_A15; /* r4p0 cpu, not requiring expensive tlb flush errata */ cpu->midr =3D 0x414fc0f0; @@ -622,14 +602,13 @@ static void cortex_a15_initfn(Object *obj) cpu->ccsidr[1] =3D 0x201fe00a; /* 32K L1 icache */ cpu->ccsidr[2] =3D 0x711fe07a; /* 4096K L2 unified cache */ cpu->isar.reset_pmcr_el0 =3D 0x410F3000; - define_arm_cp_regs(cpu, cortexa15_cp_reginfo); + define_arm_cp_regs_with_class(cpu, cortexa15_cp_reginfo, NULL); } =20 -static void cortex_m0_initfn(Object *obj) +static void cortex_m0_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - set_feature(&cpu->env, ARM_FEATURE_V6); - set_feature(&cpu->env, ARM_FEATURE_M); + set_class_feature(cpu, ARM_FEATURE_V6); + set_class_feature(cpu, ARM_FEATURE_M); =20 cpu->midr =3D 0x410cc200; =20 @@ -658,12 +637,11 @@ static void cortex_m0_initfn(Object *obj) cpu->isar.id_isar6 =3D 0x00000000; } =20 -static void cortex_m3_initfn(Object *obj) +static void cortex_m3_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - set_feature(&cpu->env, ARM_FEATURE_V7); - set_feature(&cpu->env, ARM_FEATURE_M); - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); + set_class_feature(cpu, ARM_FEATURE_V7); + set_class_feature(cpu, ARM_FEATURE_M); + set_class_feature(cpu, ARM_FEATURE_M_MAIN); cpu->midr =3D 0x410fc231; cpu->pmsav7_dregion =3D 8; cpu->isar.id_pfr0 =3D 0x00000030; @@ -683,14 +661,12 @@ static void cortex_m3_initfn(Object *obj) cpu->isar.id_isar6 =3D 0x00000000; } =20 -static void cortex_m4_initfn(Object *obj) +static void cortex_m4_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - - set_feature(&cpu->env, ARM_FEATURE_V7); - set_feature(&cpu->env, ARM_FEATURE_M); - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); + set_class_feature(cpu, ARM_FEATURE_V7); + set_class_feature(cpu, ARM_FEATURE_M); + set_class_feature(cpu, ARM_FEATURE_M_MAIN); + set_class_feature(cpu, ARM_FEATURE_THUMB_DSP); cpu->midr =3D 0x410fc240; /* r0p0 */ cpu->pmsav7_dregion =3D 8; cpu->isar.mvfr0 =3D 0x10110021; @@ -713,14 +689,12 @@ static void cortex_m4_initfn(Object *obj) cpu->isar.id_isar6 =3D 0x00000000; } =20 -static void cortex_m7_initfn(Object *obj) +static void cortex_m7_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - - set_feature(&cpu->env, ARM_FEATURE_V7); - set_feature(&cpu->env, ARM_FEATURE_M); - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); + set_class_feature(cpu, ARM_FEATURE_V7); + set_class_feature(cpu, ARM_FEATURE_M); + set_class_feature(cpu, ARM_FEATURE_M_MAIN); + set_class_feature(cpu, ARM_FEATURE_THUMB_DSP); cpu->midr =3D 0x411fc272; /* r1p2 */ cpu->pmsav7_dregion =3D 8; cpu->isar.mvfr0 =3D 0x10110221; @@ -743,15 +717,13 @@ static void cortex_m7_initfn(Object *obj) cpu->isar.id_isar6 =3D 0x00000000; } =20 -static void cortex_m33_initfn(Object *obj) +static void cortex_m33_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - - set_feature(&cpu->env, ARM_FEATURE_V8); - set_feature(&cpu->env, ARM_FEATURE_M); - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); - set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); + set_class_feature(cpu, ARM_FEATURE_V8); + set_class_feature(cpu, ARM_FEATURE_M); + set_class_feature(cpu, ARM_FEATURE_M_MAIN); + set_class_feature(cpu, ARM_FEATURE_M_SECURITY); + set_class_feature(cpu, ARM_FEATURE_THUMB_DSP); cpu->midr =3D 0x410fd213; /* r0p3 */ cpu->pmsav7_dregion =3D 16; cpu->sau_sregion =3D 8; @@ -777,16 +749,14 @@ static void cortex_m33_initfn(Object *obj) cpu->ctr =3D 0x8000c000; } =20 -static void cortex_m55_initfn(Object *obj) +static void cortex_m55_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - - set_feature(&cpu->env, ARM_FEATURE_V8); - set_feature(&cpu->env, ARM_FEATURE_V8_1M); - set_feature(&cpu->env, ARM_FEATURE_M); - set_feature(&cpu->env, ARM_FEATURE_M_MAIN); - set_feature(&cpu->env, ARM_FEATURE_M_SECURITY); - set_feature(&cpu->env, ARM_FEATURE_THUMB_DSP); + set_class_feature(cpu, ARM_FEATURE_V8); + set_class_feature(cpu, ARM_FEATURE_V8_1M); + set_class_feature(cpu, ARM_FEATURE_M); + set_class_feature(cpu, ARM_FEATURE_M_MAIN); + set_class_feature(cpu, ARM_FEATURE_M_SECURITY); + set_class_feature(cpu, ARM_FEATURE_THUMB_DSP); cpu->midr =3D 0x410fd221; /* r0p1 */ cpu->revidr =3D 0; cpu->pmsav7_dregion =3D 16; @@ -824,14 +794,12 @@ static const ARMCPRegInfo cortexr5_cp_reginfo[] =3D { .opc2 =3D 0, .access =3D PL1_W, .type =3D ARM_CP_NOP }, }; =20 -static void cortex_r5_initfn(Object *obj) +static void cortex_r5_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - - set_feature(&cpu->env, ARM_FEATURE_V7); - set_feature(&cpu->env, ARM_FEATURE_V7MP); - set_feature(&cpu->env, ARM_FEATURE_PMSA); - set_feature(&cpu->env, ARM_FEATURE_PMU); + set_class_feature(cpu, ARM_FEATURE_V7); + set_class_feature(cpu, ARM_FEATURE_V7MP); + set_class_feature(cpu, ARM_FEATURE_PMSA); + set_class_feature(cpu, ARM_FEATURE_PMU); cpu->midr =3D 0x411fc153; /* r1p3 */ cpu->isar.id_pfr0 =3D 0x0131; cpu->isar.id_pfr1 =3D 0x001; @@ -850,181 +818,153 @@ static void cortex_r5_initfn(Object *obj) cpu->isar.id_isar6 =3D 0x0; cpu->pmsav7_dregion =3D 16; cpu->isar.reset_pmcr_el0 =3D 0x41151800; - define_arm_cp_regs(cpu, cortexr5_cp_reginfo); + define_arm_cp_regs_with_class(cpu, cortexr5_cp_reginfo, NULL); } =20 -static void cortex_r5f_initfn(Object *obj) +static void cortex_r5f_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - - cortex_r5_initfn(obj); + cortex_r5_class_init(cpu); cpu->isar.mvfr0 =3D 0x10110221; cpu->isar.mvfr1 =3D 0x00000011; } =20 -static void ti925t_initfn(Object *obj) +static void ti925t_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - set_feature(&cpu->env, ARM_FEATURE_V4T); - set_feature(&cpu->env, ARM_FEATURE_OMAPCP); + set_class_feature(cpu, ARM_FEATURE_V4T); + set_class_feature(cpu, ARM_FEATURE_OMAPCP); cpu->midr =3D ARM_CPUID_TI925T; cpu->ctr =3D 0x5109149; cpu->reset_sctlr =3D 0x00000070; } =20 -static void sa1100_initfn(Object *obj) +static void sa1100_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "intel,sa1100"; - set_feature(&cpu->env, ARM_FEATURE_STRONGARM); - set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); + set_class_feature(cpu, ARM_FEATURE_STRONGARM); + set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); cpu->midr =3D 0x4401A11B; cpu->reset_sctlr =3D 0x00000070; } =20 -static void sa1110_initfn(Object *obj) +static void sa1110_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - set_feature(&cpu->env, ARM_FEATURE_STRONGARM); - set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); + set_class_feature(cpu, ARM_FEATURE_STRONGARM); + set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); cpu->midr =3D 0x6901B119; cpu->reset_sctlr =3D 0x00000070; } =20 -static void pxa250_initfn(Object *obj) +static void pxa250_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "marvell,xscale"; - set_feature(&cpu->env, ARM_FEATURE_V5); - set_feature(&cpu->env, ARM_FEATURE_XSCALE); + set_class_feature(cpu, ARM_FEATURE_V5); + set_class_feature(cpu, ARM_FEATURE_XSCALE); cpu->midr =3D 0x69052100; cpu->ctr =3D 0xd172172; cpu->reset_sctlr =3D 0x00000078; } =20 -static void pxa255_initfn(Object *obj) +static void pxa255_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "marvell,xscale"; - set_feature(&cpu->env, ARM_FEATURE_V5); - set_feature(&cpu->env, ARM_FEATURE_XSCALE); + set_class_feature(cpu, ARM_FEATURE_V5); + set_class_feature(cpu, ARM_FEATURE_XSCALE); cpu->midr =3D 0x69052d00; cpu->ctr =3D 0xd172172; cpu->reset_sctlr =3D 0x00000078; } =20 -static void pxa260_initfn(Object *obj) +static void pxa260_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "marvell,xscale"; - set_feature(&cpu->env, ARM_FEATURE_V5); - set_feature(&cpu->env, ARM_FEATURE_XSCALE); + set_class_feature(cpu, ARM_FEATURE_V5); + set_class_feature(cpu, ARM_FEATURE_XSCALE); cpu->midr =3D 0x69052903; cpu->ctr =3D 0xd172172; cpu->reset_sctlr =3D 0x00000078; } =20 -static void pxa261_initfn(Object *obj) +static void pxa261_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "marvell,xscale"; - set_feature(&cpu->env, ARM_FEATURE_V5); - set_feature(&cpu->env, ARM_FEATURE_XSCALE); + set_class_feature(cpu, ARM_FEATURE_V5); + set_class_feature(cpu, ARM_FEATURE_XSCALE); cpu->midr =3D 0x69052d05; cpu->ctr =3D 0xd172172; cpu->reset_sctlr =3D 0x00000078; } =20 -static void pxa262_initfn(Object *obj) +static void pxa262_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "marvell,xscale"; - set_feature(&cpu->env, ARM_FEATURE_V5); - set_feature(&cpu->env, ARM_FEATURE_XSCALE); + set_class_feature(cpu, ARM_FEATURE_V5); + set_class_feature(cpu, ARM_FEATURE_XSCALE); cpu->midr =3D 0x69052d06; cpu->ctr =3D 0xd172172; cpu->reset_sctlr =3D 0x00000078; } =20 -static void pxa270a0_initfn(Object *obj) +static void pxa270a0_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "marvell,xscale"; - set_feature(&cpu->env, ARM_FEATURE_V5); - set_feature(&cpu->env, ARM_FEATURE_XSCALE); - set_feature(&cpu->env, ARM_FEATURE_IWMMXT); + set_class_feature(cpu, ARM_FEATURE_V5); + set_class_feature(cpu, ARM_FEATURE_XSCALE); + set_class_feature(cpu, ARM_FEATURE_IWMMXT); cpu->midr =3D 0x69054110; cpu->ctr =3D 0xd172172; cpu->reset_sctlr =3D 0x00000078; } =20 -static void pxa270a1_initfn(Object *obj) +static void pxa270a1_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "marvell,xscale"; - set_feature(&cpu->env, ARM_FEATURE_V5); - set_feature(&cpu->env, ARM_FEATURE_XSCALE); - set_feature(&cpu->env, ARM_FEATURE_IWMMXT); + set_class_feature(cpu, ARM_FEATURE_V5); + set_class_feature(cpu, ARM_FEATURE_XSCALE); + set_class_feature(cpu, ARM_FEATURE_IWMMXT); cpu->midr =3D 0x69054111; cpu->ctr =3D 0xd172172; cpu->reset_sctlr =3D 0x00000078; } =20 -static void pxa270b0_initfn(Object *obj) +static void pxa270b0_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "marvell,xscale"; - set_feature(&cpu->env, ARM_FEATURE_V5); - set_feature(&cpu->env, ARM_FEATURE_XSCALE); - set_feature(&cpu->env, ARM_FEATURE_IWMMXT); + set_class_feature(cpu, ARM_FEATURE_V5); + set_class_feature(cpu, ARM_FEATURE_XSCALE); + set_class_feature(cpu, ARM_FEATURE_IWMMXT); cpu->midr =3D 0x69054112; cpu->ctr =3D 0xd172172; cpu->reset_sctlr =3D 0x00000078; } =20 -static void pxa270b1_initfn(Object *obj) +static void pxa270b1_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "marvell,xscale"; - set_feature(&cpu->env, ARM_FEATURE_V5); - set_feature(&cpu->env, ARM_FEATURE_XSCALE); - set_feature(&cpu->env, ARM_FEATURE_IWMMXT); + set_class_feature(cpu, ARM_FEATURE_V5); + set_class_feature(cpu, ARM_FEATURE_XSCALE); + set_class_feature(cpu, ARM_FEATURE_IWMMXT); cpu->midr =3D 0x69054113; cpu->ctr =3D 0xd172172; cpu->reset_sctlr =3D 0x00000078; } =20 -static void pxa270c0_initfn(Object *obj) +static void pxa270c0_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "marvell,xscale"; - set_feature(&cpu->env, ARM_FEATURE_V5); - set_feature(&cpu->env, ARM_FEATURE_XSCALE); - set_feature(&cpu->env, ARM_FEATURE_IWMMXT); + set_class_feature(cpu, ARM_FEATURE_V5); + set_class_feature(cpu, ARM_FEATURE_XSCALE); + set_class_feature(cpu, ARM_FEATURE_IWMMXT); cpu->midr =3D 0x69054114; cpu->ctr =3D 0xd172172; cpu->reset_sctlr =3D 0x00000078; } =20 -static void pxa270c5_initfn(Object *obj) +static void pxa270c5_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - cpu->dtb_compatible =3D "marvell,xscale"; - set_feature(&cpu->env, ARM_FEATURE_V5); - set_feature(&cpu->env, ARM_FEATURE_XSCALE); - set_feature(&cpu->env, ARM_FEATURE_IWMMXT); + set_class_feature(cpu, ARM_FEATURE_V5); + set_class_feature(cpu, ARM_FEATURE_XSCALE); + set_class_feature(cpu, ARM_FEATURE_IWMMXT); cpu->midr =3D 0x69054117; cpu->ctr =3D 0xd172172; cpu->reset_sctlr =3D 0x00000078; @@ -1070,19 +1010,17 @@ static void arm_v7m_class_init(ObjectClass *oc, voi= d *data) * The version of '-cpu max' for qemu-system-aarch64 is defined in cpu64.c; * this only needs to handle 32 bits, and need not care about KVM. */ -static void arm_max_initfn(Object *obj) +static void arm_max_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu =3D ARM_CPU(obj); - - /* aarch64_a57_initfn, advertising none of the aarch64 features */ + /* aarch64_a57_class_init, advertising none of the aarch64 features */ cpu->dtb_compatible =3D "arm,cortex-a57"; - set_feature(&cpu->env, ARM_FEATURE_V8); - set_feature(&cpu->env, ARM_FEATURE_NEON); - set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); - set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); - set_feature(&cpu->env, ARM_FEATURE_EL2); - set_feature(&cpu->env, ARM_FEATURE_EL3); - set_feature(&cpu->env, ARM_FEATURE_PMU); + set_class_feature(cpu, ARM_FEATURE_V8); + set_class_feature(cpu, ARM_FEATURE_NEON); + set_class_feature(cpu, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(cpu, ARM_FEATURE_CBAR_RO); + set_class_feature(cpu, ARM_FEATURE_EL2); + set_class_feature(cpu, ARM_FEATURE_EL3); + set_class_feature(cpu, ARM_FEATURE_PMU); cpu->midr =3D 0x411fd070; cpu->revidr =3D 0x00000000; cpu->reset_fpsid =3D 0x41034070; @@ -1130,55 +1068,55 @@ static void arm_max_initfn(Object *obj) #endif /* !TARGET_AARCH64 */ =20 static const ARMCPUInfo arm_tcg_cpus[] =3D { - { .name =3D "arm926", .initfn =3D arm926_initfn }, - { .name =3D "arm946", .initfn =3D arm946_initfn }, - { .name =3D "arm1026", .initfn =3D arm1026_initfn }, + { .name =3D "arm926", .class_init =3D arm926_class_init }, + { .name =3D "arm946", .class_init =3D arm946_class_init }, + { .name =3D "arm1026", .class_init =3D arm1026_class_init }, /* * What QEMU calls "arm1136-r2" is actually the 1136 r0p2, i.e. an * older core than plain "arm1136". In particular this does not * have the v6K features. */ - { .name =3D "arm1136-r2", .initfn =3D arm1136_r2_initfn }, - { .name =3D "arm1136", .initfn =3D arm1136_initfn }, - { .name =3D "arm1176", .initfn =3D arm1176_initfn }, - { .name =3D "arm11mpcore", .initfn =3D arm11mpcore_initfn }, - { .name =3D "cortex-a7", .initfn =3D cortex_a7_initfn }, - { .name =3D "cortex-a8", .initfn =3D cortex_a8_initfn }, - { .name =3D "cortex-a9", .initfn =3D cortex_a9_initfn }, - { .name =3D "cortex-a15", .initfn =3D cortex_a15_initfn }, - { .name =3D "cortex-r5", .initfn =3D cortex_r5_initfn }, - { .name =3D "cortex-r5f", .initfn =3D cortex_r5f_initfn }, - { .name =3D "ti925t", .initfn =3D ti925t_initfn }, - { .name =3D "sa1100", .initfn =3D sa1100_initfn }, - { .name =3D "sa1110", .initfn =3D sa1110_initfn }, - { .name =3D "pxa250", .initfn =3D pxa250_initfn }, - { .name =3D "pxa255", .initfn =3D pxa255_initfn }, - { .name =3D "pxa260", .initfn =3D pxa260_initfn }, - { .name =3D "pxa261", .initfn =3D pxa261_initfn }, - { .name =3D "pxa262", .initfn =3D pxa262_initfn }, + { .name =3D "arm1136-r2", .class_init =3D arm1136_r2_class_init }, + { .name =3D "arm1136", .class_init =3D arm1136_class_init }, + { .name =3D "arm1176", .class_init =3D arm1176_class_init }, + { .name =3D "arm11mpcore", .class_init =3D arm11mpcore_class_init }, + { .name =3D "cortex-a7", .class_init =3D cortex_a7_class_init }, + { .name =3D "cortex-a8", .class_init =3D cortex_a8_class_init }, + { .name =3D "cortex-a9", .class_init =3D cortex_a9_class_init }, + { .name =3D "cortex-a15", .class_init =3D cortex_a15_class_init }, + { .name =3D "cortex-r5", .class_init =3D cortex_r5_class_init }, + { .name =3D "cortex-r5f", .class_init =3D cortex_r5f_class_init }, + { .name =3D "ti925t", .class_init =3D ti925t_class_init }, + { .name =3D "sa1100", .class_init =3D sa1100_class_init }, + { .name =3D "sa1110", .class_init =3D sa1110_class_init }, + { .name =3D "pxa250", .class_init =3D pxa250_class_init }, + { .name =3D "pxa255", .class_init =3D pxa255_class_init }, + { .name =3D "pxa260", .class_init =3D pxa260_class_init }, + { .name =3D "pxa261", .class_init =3D pxa261_class_init }, + { .name =3D "pxa262", .class_init =3D pxa262_class_init }, /* "pxa270" is an alias for "pxa270-a0" */ - { .name =3D "pxa270", .initfn =3D pxa270a0_initfn }, - { .name =3D "pxa270-a0", .initfn =3D pxa270a0_initfn }, - { .name =3D "pxa270-a1", .initfn =3D pxa270a1_initfn }, - { .name =3D "pxa270-b0", .initfn =3D pxa270b0_initfn }, - { .name =3D "pxa270-b1", .initfn =3D pxa270b1_initfn }, - { .name =3D "pxa270-c0", .initfn =3D pxa270c0_initfn }, - { .name =3D "pxa270-c5", .initfn =3D pxa270c5_initfn }, + { .name =3D "pxa270", .class_init =3D pxa270a0_class_init }, + { .name =3D "pxa270-a0", .class_init =3D pxa270a0_class_init }, + { .name =3D "pxa270-a1", .class_init =3D pxa270a1_class_init }, + { .name =3D "pxa270-b0", .class_init =3D pxa270b0_class_init }, + { .name =3D "pxa270-b1", .class_init =3D pxa270b1_class_init }, + { .name =3D "pxa270-c0", .class_init =3D pxa270c0_class_init }, + { .name =3D "pxa270-c5", .class_init =3D pxa270c5_class_init }, #ifndef TARGET_AARCH64 - { .name =3D "max", .initfn =3D arm_max_initfn }, + { .name =3D "max", .class_init =3D arm_max_class_init }, #endif #ifdef CONFIG_USER_ONLY - { .name =3D "any", .initfn =3D arm_max_initfn }, + { .name =3D "any", .class_init =3D arm_max_class_init }, #endif }; =20 static const ARMCPUInfo arm_v7m_tcg_cpus[] =3D { - { .name =3D "cortex-m0", .initfn =3D cortex_m0_initfn }, - { .name =3D "cortex-m3", .initfn =3D cortex_m3_initfn }, - { .name =3D "cortex-m4", .initfn =3D cortex_m4_initfn }, - { .name =3D "cortex-m7", .initfn =3D cortex_m7_initfn }, - { .name =3D "cortex-m33", .initfn =3D cortex_m33_initfn }, - { .name =3D "cortex-m55", .initfn =3D cortex_m55_initfn }, + { .name =3D "cortex-m0", .class_init =3D cortex_m0_class_init }, + { .name =3D "cortex-m3", .class_init =3D cortex_m3_class_init }, + { .name =3D "cortex-m4", .class_init =3D cortex_m4_class_init }, + { .name =3D "cortex-m7", .class_init =3D cortex_m7_class_init }, + { .name =3D "cortex-m33", .class_init =3D cortex_m33_class_init }, + { .name =3D "cortex-m55", .class_init =3D cortex_m55_class_init }, }; =20 static const TypeInfo arm_v7m_cpu_type_info =3D { --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770197; cv=none; d=zohomail.com; s=zohoarc; b=jRq92d0gaZG9unSdkeQhH614oYduE/1O/beb37xK/dG/eeu/7P/O/RAJ7+0xhSFgUiKLnmQlZRnHGUeEcqr2xN2o2Hv6qMlM9s13xYnplk0pe2vyelNAMRcixNeR97CZuT2LytxHCN6zU4tOZB8R7rGYhmRs9bR2VFObic/fEwc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770197; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=WOgkxoomlodohQOeAEcc5A6oSk0mtn0fP77laaeYcB0=; b=k3e6KLfSoEylbfroKiR4RAyyrPWH6WeEj0ujvoklCDX41YS4gZnqI0h65s31UjluI/xhTcBwqt3NsQrmAPqjEwtBskjn5pwEoMOXmcZoA0njZWRz2nYa06lhXgjRDrlfZz7gFXuKooeI2uRK8EdGuahTQRdxrmuBThOEQtKpdc8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770197745973.9670595922613; Tue, 3 Jan 2023 10:23:17 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrc-0000Au-6X; Tue, 03 Jan 2023 13:18:16 -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 1pClrI-0008NU-Tb for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:57 -0500 Received: from mail-vs1-xe30.google.com ([2607:f8b0:4864:20::e30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClrE-0005Gi-13 for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:56 -0500 Received: by mail-vs1-xe30.google.com with SMTP id i188so32587025vsi.8 for ; Tue, 03 Jan 2023 10:17:51 -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.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:49 -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=WOgkxoomlodohQOeAEcc5A6oSk0mtn0fP77laaeYcB0=; b=tzz/tsxN9uS5qnqhLorwtjdHaIXqpbccSaco+3ubfVNBtft/TiI2jbFNPa8+wyRUzw pRSsM0CX099eR2tbasxAEfjLHb57dreWrWhd2Wa8ABstMNElHpvFi1/PgsxOLqkoxLra iFJo6zcYV6+eUZJpU1aLyGH1gT3A9diciiZN6sDxmvD15yYCDQdKoA5dE6YD/CICS5RB oUDDhlsyh8iLYEX87srnzIEa4oVWxRezdIV4vv8KDQa+IkESrSfDMSbdawiO3ZCr+fB6 Pd2vBkzfbUHhgMDmIUWUYplQf4VjHHGQvERj0sVgT7uo3X5a/uDMN/9rf8Q1GCjGweYQ FENw== 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=WOgkxoomlodohQOeAEcc5A6oSk0mtn0fP77laaeYcB0=; b=S8D0DJlC/fID1+BpUTzO0/vl/7QC0rRPPmy2hpERpHP3r45qomKSsE1FUAGOfWS1zW 5vulNFskzpLC5yTvvl+XZuoYySl0l2AeiYzAoHAo4IOHrwbIIvQxAp5V2Bhd6WOCrNmL SbqdwEJKalKw0YfNdDmhhrH+qLduFNAa3ekoqFCiUAGaullVt/R2qI8HL7hdYPgNt26B qOeFMdMkqx9Z8AWEzSBtmFPCYB38owMwBr3klo9g5tnuugrVp7Hyx2wv47PwgnQW0EW7 lf50jF2YAPcxjRzxXzSbSTx7b2n6s+gdbdY0lmm7sIbrJD0zLi6oeqUhkGl/LjYlVqoL 4UnA== X-Gm-Message-State: AFqh2kq5pmnS24h9lGzfiS9oMbLWEKopY6R9jfvN+LUKNh9yeJtUrw1G NiLiKTfTH4Lm6l6zEYeV9Q16UA6ngk7O+kOQLRg= X-Google-Smtp-Source: AMrXdXs+Egv0neLb71iXpduZqpDPlsPJYx1Cb4VWGb6pCEkNYGY+YzP0k85A9j6FebCbZ2Xtk28VRA== X-Received: by 2002:a67:f406:0:b0:3ca:f257:9f95 with SMTP id p6-20020a67f406000000b003caf2579f95mr12867591vsn.0.1672769870038; Tue, 03 Jan 2023 10:17:50 -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 20/40] target/arm: Merge kvm64.c with kvm.c Date: Tue, 3 Jan 2023 10:16:26 -0800 Message-Id: <20230103181646.55711-21-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 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::e30; envelope-from=richard.henderson@linaro.org; helo=mail-vs1-xe30.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770199855100007 With appropriate sorting of functions, this allows quite a number of prototypes to be removed from kvm_arm.h, and the corresponding functions made static. Signed-off-by: Richard Henderson --- target/arm/kvm_arm.h | 190 ---- target/arm/kvm.c | 2048 +++++++++++++++++++++++++++++++++++++--- target/arm/kvm64.c | 1632 -------------------------------- target/arm/meson.build | 2 +- 4 files changed, 1896 insertions(+), 1976 deletions(-) delete mode 100644 target/arm/kvm64.c diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index 99017b635c..8efbe0cc4b 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -18,32 +18,6 @@ #define KVM_ARM_VGIC_V2 (1 << 0) #define KVM_ARM_VGIC_V3 (1 << 1) =20 -/** - * kvm_arm_vcpu_init: - * @cs: CPUState - * - * Initialize (or reinitialize) the VCPU by invoking the - * KVM_ARM_VCPU_INIT ioctl with the CPU type and feature - * bitmask specified in the CPUState. - * - * Returns: 0 if success else < 0 error code - */ -int kvm_arm_vcpu_init(CPUState *cs); - -/** - * kvm_arm_vcpu_finalize: - * @cs: CPUState - * @feature: feature to finalize - * - * Finalizes the configuration of the specified VCPU feature by - * invoking the KVM_ARM_VCPU_FINALIZE ioctl. Features requiring - * this are documented in the "KVM_ARM_VCPU_FINALIZE" section of - * KVM's API documentation. - * - * Returns: 0 if success else < 0 error code - */ -int kvm_arm_vcpu_finalize(CPUState *cs, int feature); - /** * kvm_arm_register_device: * @mr: memory region for this device @@ -65,37 +39,6 @@ int kvm_arm_vcpu_finalize(CPUState *cs, int feature); void kvm_arm_register_device(MemoryRegion *mr, uint64_t devid, uint64_t gr= oup, uint64_t attr, int dev_fd, uint64_t addr_orma= sk); =20 -/** - * kvm_arm_init_cpreg_list: - * @cpu: ARMCPU - * - * Initialize the ARMCPU cpreg list according to the kernel's - * definition of what CPU registers it knows about (and throw away - * the previous TCG-created cpreg list). - * - * Returns: 0 if success, else < 0 error code - */ -int kvm_arm_init_cpreg_list(ARMCPU *cpu); - -/** - * kvm_arm_reg_syncs_via_cpreg_list: - * @regidx: KVM register index - * - * Return true if this KVM register should be synchronized via the - * cpreg list of arbitrary system registers, false if it is synchronized - * by hand using code in kvm_arch_get/put_registers(). - */ -bool kvm_arm_reg_syncs_via_cpreg_list(uint64_t regidx); - -/** - * kvm_arm_cpreg_level: - * @regidx: KVM register index - * - * Return the level of this coprocessor/system register. Return value is - * either KVM_PUT_RUNTIME_STATE, KVM_PUT_RESET_STATE, or KVM_PUT_FULL_STAT= E. - */ -int kvm_arm_cpreg_level(uint64_t regidx); - /** * write_list_to_kvmstate: * @cpu: ARMCPU @@ -155,34 +98,6 @@ void kvm_arm_cpu_post_load(ARMCPU *cpu); */ void kvm_arm_reset_vcpu(ARMCPU *cpu); =20 -/** - * kvm_arm_init_serror_injection: - * @cs: CPUState - * - * Check whether KVM can set guest SError syndrome. - */ -void kvm_arm_init_serror_injection(CPUState *cs); - -/** - * kvm_get_vcpu_events: - * @cpu: ARMCPU - * - * Get VCPU related state from kvm. - * - * Returns: 0 if success else < 0 error code - */ -int kvm_get_vcpu_events(ARMCPU *cpu); - -/** - * kvm_put_vcpu_events: - * @cpu: ARMCPU - * - * Put VCPU related state to kvm. - * - * Returns: 0 if success else < 0 error code - */ -int kvm_put_vcpu_events(ARMCPU *cpu); - #ifdef CONFIG_KVM /** * kvm_arm_create_scratch_host_vcpu: @@ -214,28 +129,6 @@ bool kvm_arm_create_scratch_host_vcpu(const uint32_t *= cpus_to_try, */ void kvm_arm_destroy_scratch_host_vcpu(int *fdarray); =20 -/** - * ARMHostCPUFeatures: information about the host CPU (identified - * by asking the host kernel) - */ -typedef struct ARMHostCPUFeatures { - ARMISARegisters isar; - uint64_t features; - uint32_t target; - const char *dtb_compatible; -} ARMHostCPUFeatures; - -/** - * kvm_arm_get_host_cpu_features: - * @ahcf: ARMHostCPUClass to fill in - * - * Probe the capabilities of the host kernel's preferred CPU and fill - * in the ARMHostCPUClass struct accordingly. - * - * Returns true on success and false otherwise. - */ -bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf); - /** * kvm_arm_sve_get_vls: * @cs: CPUState @@ -274,14 +167,6 @@ void kvm_arm_add_vcpu_properties(Object *obj); */ void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp); =20 -/** - * kvm_arm_steal_time_supported: - * - * Returns: true if KVM can enable steal time reporting - * and false otherwise. - */ -bool kvm_arm_steal_time_supported(void); - /** * kvm_arm_aarch32_supported: * @@ -315,44 +200,6 @@ bool kvm_arm_sve_supported(void); */ int kvm_arm_get_max_vm_ipa_size(MachineState *ms, bool *fixed_ipa); =20 -/** - * kvm_arm_sync_mpstate_to_kvm: - * @cpu: ARMCPU - * - * If supported set the KVM MP_STATE based on QEMU's model. - * - * Returns 0 on success and -1 on failure. - */ -int kvm_arm_sync_mpstate_to_kvm(ARMCPU *cpu); - -/** - * kvm_arm_sync_mpstate_to_qemu: - * @cpu: ARMCPU - * - * If supported get the MP_STATE from KVM and store in QEMU's model. - * - * Returns 0 on success and aborts on failure. - */ -int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu); - -/** - * kvm_arm_get_virtual_time: - * @cs: CPUState - * - * Gets the VCPU's virtual counter and stores it in the KVM CPU state. - */ -void kvm_arm_get_virtual_time(CPUState *cs); - -/** - * kvm_arm_put_virtual_time: - * @cs: CPUState - * - * Sets the VCPU's virtual counter to the value stored in the KVM CPU stat= e. - */ -void kvm_arm_put_virtual_time(CPUState *cs); - -void kvm_arm_vm_state_change(void *opaque, bool running, RunState state); - int kvm_arm_vgic_probe(void); =20 void kvm_arm_pmu_set_irq(CPUState *cs, int irq); @@ -471,43 +318,6 @@ static inline const char *gicv3_class_name(void) } } =20 -/** - * kvm_arm_handle_debug: - * @cs: CPUState - * @debug_exit: debug part of the KVM exit structure - * - * Returns: TRUE if the debug exception was handled. - */ -bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_= exit); - -/** - * kvm_arm_hw_debug_active: - * @cs: CPU State - * - * Return: TRUE if any hardware breakpoints in use. - */ -bool kvm_arm_hw_debug_active(CPUState *cs); - -/** - * kvm_arm_copy_hw_debug_data: - * @ptr: kvm_guest_debug_arch structure - * - * Copy the architecture specific debug registers into the - * kvm_guest_debug ioctl structure. - */ -struct kvm_guest_debug_arch; -void kvm_arm_copy_hw_debug_data(struct kvm_guest_debug_arch *ptr); - -/** - * kvm_arm_verify_ext_dabt_pending: - * @cs: CPUState - * - * Verify the fault status code wrt the Ext DABT injection - * - * Returns: true if the fault status code is as expected, false otherwise - */ -bool kvm_arm_verify_ext_dabt_pending(CPUState *cs); - /** * its_class_name: * diff --git a/target/arm/kvm.c b/target/arm/kvm.c index f022c644d2..02a15c6013 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -19,6 +19,7 @@ #include "qom/object.h" #include "qapi/error.h" #include "sysemu/sysemu.h" +#include "sysemu/runstate.h" #include "sysemu/kvm.h" #include "sysemu/kvm_int.h" #include "kvm_arm.h" @@ -28,8 +29,11 @@ #include "hw/pci/pci.h" #include "exec/memattrs.h" #include "exec/address-spaces.h" +#include "exec/gdbstub.h" #include "hw/boards.h" #include "hw/irq.h" +#include "hw/acpi/acpi.h" +#include "hw/acpi/ghes.h" #include "qemu/log.h" =20 const KVMCapabilityInfo kvm_arch_required_capabilities[] =3D { @@ -40,9 +44,30 @@ static bool cap_has_mp_state; static bool cap_has_inject_serror_esr; static bool cap_has_inject_ext_dabt; =20 +/** + * ARMHostCPUFeatures: information about the host CPU (identified + * by asking the host kernel) + */ +typedef struct ARMHostCPUFeatures { + ARMISARegisters isar; + uint64_t features; + uint32_t target; + const char *dtb_compatible; +} ARMHostCPUFeatures; + static ARMHostCPUFeatures arm_host_cpu_features; =20 -int kvm_arm_vcpu_init(CPUState *cs) +/** + * kvm_arm_vcpu_init: + * @cs: CPUState + * + * Initialize (or reinitialize) the VCPU by invoking the + * KVM_ARM_VCPU_INIT ioctl with the CPU type and feature + * bitmask specified in the CPUState. + * + * Returns: 0 if success else < 0 error code + */ +static int kvm_arm_vcpu_init(CPUState *cs) { ARMCPU *cpu =3D ARM_CPU(cs); struct kvm_vcpu_init init; @@ -53,12 +78,30 @@ int kvm_arm_vcpu_init(CPUState *cs) return kvm_vcpu_ioctl(cs, KVM_ARM_VCPU_INIT, &init); } =20 -int kvm_arm_vcpu_finalize(CPUState *cs, int feature) +/** + * kvm_arm_vcpu_finalize: + * @cs: CPUState + * @feature: feature to finalize + * + * Finalizes the configuration of the specified VCPU feature by + * invoking the KVM_ARM_VCPU_FINALIZE ioctl. Features requiring + * this are documented in the "KVM_ARM_VCPU_FINALIZE" section of + * KVM's API documentation. + * + * Returns: 0 if success else < 0 error code + */ +static int kvm_arm_vcpu_finalize(CPUState *cs, int feature) { return kvm_vcpu_ioctl(cs, KVM_ARM_VCPU_FINALIZE, &feature); } =20 -void kvm_arm_init_serror_injection(CPUState *cs) +/** + * kvm_arm_init_serror_injection: + * @cs: CPUState + * + * Check whether KVM can set guest SError syndrome. + */ +static void kvm_arm_init_serror_injection(CPUState *cs) { cap_has_inject_serror_esr =3D kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_INJECT_SERROR_ESR); @@ -166,28 +209,6 @@ void kvm_arm_destroy_scratch_host_vcpu(int *fdarray) } } =20 -void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) -{ - CPUARMState *env =3D &cpu->env; - - if (!arm_host_cpu_features.dtb_compatible) { - if (!kvm_enabled() || - !kvm_arm_get_host_cpu_features(&arm_host_cpu_features)) { - /* We can't report this error yet, so flag that we need to - * in arm_cpu_realizefn(). - */ - cpu->kvm_target =3D QEMU_KVM_ARM_TARGET_NONE; - cpu->host_cpu_probe_failed =3D true; - return; - } - } - - cpu->kvm_target =3D arm_host_cpu_features.target; - cpu->dtb_compatible =3D arm_host_cpu_features.dtb_compatible; - cpu->isar =3D arm_host_cpu_features.isar; - env->features =3D arm_host_cpu_features.features; -} - static bool kvm_no_adjvtime_get(Object *obj, Error **errp) { return !ARM_CPU(obj)->kvm_adjvtime; @@ -438,11 +459,40 @@ static uint64_t *kvm_arm_get_cpreg_ptr(ARMCPU *cpu, u= int64_t regidx) return &cpu->cpreg_values[res - cpu->cpreg_indexes]; } =20 -/* Initialize the ARMCPU cpreg list according to the kernel's +/** + * kvm_arm_reg_syncs_via_cpreg_list: + * @regidx: KVM register index + * + * Return true if this KVM register should be synchronized via the + * cpreg list of arbitrary system registers, false if it is synchronized + * by hand using code in kvm_arch_get/put_registers(). + */ +static bool kvm_arm_reg_syncs_via_cpreg_list(uint64_t regidx) +{ + /* Return true if the regidx is a register we should synchronize + * via the cpreg_tuples array (ie is not a core or sve reg that + * we sync by hand in kvm_arch_get/put_registers()) + */ + switch (regidx & KVM_REG_ARM_COPROC_MASK) { + case KVM_REG_ARM_CORE: + case KVM_REG_ARM64_SVE: + return false; + default: + return true; + } +} + +/** + * kvm_arm_init_cpreg_list: + * @cpu: ARMCPU + * + * Initialize the ARMCPU cpreg list according to the kernel's * definition of what CPU registers it knows about (and throw away * the previous TCG-created cpreg list). + * + * Returns: 0 if success, else < 0 error code */ -int kvm_arm_init_cpreg_list(ARMCPU *cpu) +static int kvm_arm_init_cpreg_list(ARMCPU *cpu) { struct kvm_reg_list rl; struct kvm_reg_list *rlp; @@ -551,6 +601,41 @@ bool write_kvmstate_to_list(ARMCPU *cpu) return ok; } =20 +typedef struct CPRegStateLevel { + uint64_t regidx; + int level; +} CPRegStateLevel; + +/* All system registers not listed in the following table are assumed to be + * of the level KVM_PUT_RUNTIME_STATE. If a register should be written less + * often, you must add it to this table with a state of either + * KVM_PUT_RESET_STATE or KVM_PUT_FULL_STATE. + */ +static const CPRegStateLevel non_runtime_cpregs[] =3D { + { KVM_REG_ARM_TIMER_CNT, KVM_PUT_FULL_STATE }, +}; + +/** + * kvm_arm_cpreg_level: + * @regidx: KVM register index + * + * Return the level of this coprocessor/system register. Return value is + * either KVM_PUT_RUNTIME_STATE, KVM_PUT_RESET_STATE, or KVM_PUT_FULL_STAT= E. + */ +static int kvm_arm_cpreg_level(uint64_t regidx) +{ + int i; + + for (i =3D 0; i < ARRAY_SIZE(non_runtime_cpregs); i++) { + const CPRegStateLevel *l =3D &non_runtime_cpregs[i]; + if (l->regidx =3D=3D regidx) { + return l->level; + } + } + + return KVM_PUT_RUNTIME_STATE; +} + bool write_list_to_kvmstate(ARMCPU *cpu, int level) { CPUState *cs =3D CPU(cpu); @@ -634,10 +719,15 @@ void kvm_arm_reset_vcpu(ARMCPU *cpu) write_list_to_cpustate(cpu); } =20 -/* - * Update KVM's MP_STATE based on what QEMU thinks it is +/** + * kvm_arm_sync_mpstate_to_kvm: + * @cpu: ARMCPU + * + * If supported set the KVM MP_STATE based on QEMU's model. + * + * Returns 0 on success and -1 on failure. */ -int kvm_arm_sync_mpstate_to_kvm(ARMCPU *cpu) +static int kvm_arm_sync_mpstate_to_kvm(ARMCPU *cpu) { if (cap_has_mp_state) { struct kvm_mp_state mp_state =3D { @@ -655,10 +745,15 @@ int kvm_arm_sync_mpstate_to_kvm(ARMCPU *cpu) return 0; } =20 -/* - * Sync the KVM MP_STATE into QEMU +/** + * kvm_arm_sync_mpstate_to_qemu: + * @cpu: ARMCPU + * + * If supported get the MP_STATE from KVM and store in QEMU's model. + * + * Returns 0 on success and aborts on failure. */ -int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu) +static int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu) { if (cap_has_mp_state) { struct kvm_mp_state mp_state; @@ -675,7 +770,13 @@ int kvm_arm_sync_mpstate_to_qemu(ARMCPU *cpu) return 0; } =20 -void kvm_arm_get_virtual_time(CPUState *cs) +/** + * kvm_arm_get_virtual_time: + * @cs: CPUState + * + * Gets the VCPU's virtual counter and stores it in the KVM CPU state. + */ +static void kvm_arm_get_virtual_time(CPUState *cs) { ARMCPU *cpu =3D ARM_CPU(cs); struct kvm_one_reg reg =3D { @@ -697,7 +798,13 @@ void kvm_arm_get_virtual_time(CPUState *cs) cpu->kvm_vtime_dirty =3D true; } =20 -void kvm_arm_put_virtual_time(CPUState *cs) +/** + * kvm_arm_put_virtual_time: + * @cs: CPUState + * + * Sets the VCPU's virtual counter to the value stored in the KVM CPU stat= e. + */ +static void kvm_arm_put_virtual_time(CPUState *cs) { ARMCPU *cpu =3D ARM_CPU(cs); struct kvm_one_reg reg =3D { @@ -719,7 +826,15 @@ void kvm_arm_put_virtual_time(CPUState *cs) cpu->kvm_vtime_dirty =3D false; } =20 -int kvm_put_vcpu_events(ARMCPU *cpu) +/** + * kvm_put_vcpu_events: + * @cpu: ARMCPU + * + * Put VCPU related state to kvm. + * + * Returns: 0 if success else < 0 error code + */ +static int kvm_put_vcpu_events(ARMCPU *cpu) { CPUARMState *env =3D &cpu->env; struct kvm_vcpu_events events; @@ -748,7 +863,15 @@ int kvm_put_vcpu_events(ARMCPU *cpu) return ret; } =20 -int kvm_get_vcpu_events(ARMCPU *cpu) +/** + * kvm_get_vcpu_events: + * @cpu: ARMCPU + * + * Get VCPU related state from kvm. + * + * Returns: 0 if success else < 0 error code + */ +static int kvm_get_vcpu_events(ARMCPU *cpu) { CPUARMState *env =3D &cpu->env; struct kvm_vcpu_events events; @@ -772,88 +895,7 @@ int kvm_get_vcpu_events(ARMCPU *cpu) return 0; } =20 -void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run) -{ - ARMCPU *cpu =3D ARM_CPU(cs); - CPUARMState *env =3D &cpu->env; - - if (unlikely(env->ext_dabt_raised)) { - /* - * Verifying that the ext DABT has been properly injected, - * otherwise risking indefinitely re-running the faulting instruct= ion - * Covering a very narrow case for kernels 5.5..5.5.4 - * when injected abort was misconfigured to be - * an IMPLEMENTATION DEFINED exception (for 32-bit EL1) - */ - if (!arm_feature(env, ARM_FEATURE_AARCH64) && - unlikely(!kvm_arm_verify_ext_dabt_pending(cs))) { - - error_report("Data abort exception with no valid ISS generated= by " - "guest memory access. KVM unable to emulate faulting " - "instruction. Failed to inject an external data abort " - "into the guest."); - abort(); - } - /* Clear the status */ - env->ext_dabt_raised =3D 0; - } -} - -MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run) -{ - ARMCPU *cpu; - uint32_t switched_level; - - if (kvm_irqchip_in_kernel()) { - /* - * We only need to sync timer states with user-space interrupt - * controllers, so return early and save cycles if we don't. - */ - return MEMTXATTRS_UNSPECIFIED; - } - - cpu =3D ARM_CPU(cs); - - /* Synchronize our shadowed in-kernel device irq lines with the kvm on= es */ - if (run->s.regs.device_irq_level !=3D cpu->device_irq_level) { - switched_level =3D cpu->device_irq_level ^ run->s.regs.device_irq_= level; - - qemu_mutex_lock_iothread(); - - if (switched_level & KVM_ARM_DEV_EL1_VTIMER) { - qemu_set_irq(cpu->gt_timer_outputs[GTIMER_VIRT], - !!(run->s.regs.device_irq_level & - KVM_ARM_DEV_EL1_VTIMER)); - switched_level &=3D ~KVM_ARM_DEV_EL1_VTIMER; - } - - if (switched_level & KVM_ARM_DEV_EL1_PTIMER) { - qemu_set_irq(cpu->gt_timer_outputs[GTIMER_PHYS], - !!(run->s.regs.device_irq_level & - KVM_ARM_DEV_EL1_PTIMER)); - switched_level &=3D ~KVM_ARM_DEV_EL1_PTIMER; - } - - if (switched_level & KVM_ARM_DEV_PMU) { - qemu_set_irq(cpu->pmu_interrupt, - !!(run->s.regs.device_irq_level & KVM_ARM_DEV_PMU= )); - switched_level &=3D ~KVM_ARM_DEV_PMU; - } - - if (switched_level) { - qemu_log_mask(LOG_UNIMP, "%s: unhandled in-kernel device IRQ %= x\n", - __func__, switched_level); - } - - /* We also mark unknown levels as processed to not waste cycles */ - cpu->device_irq_level =3D run->s.regs.device_irq_level; - qemu_mutex_unlock_iothread(); - } - - return MEMTXATTRS_UNSPECIFIED; -} - -void kvm_arm_vm_state_change(void *opaque, bool running, RunState state) +static void kvm_arm_vm_state_change(void *opaque, bool running, RunState s= tate) { CPUState *cs =3D opaque; ARMCPU *cpu =3D ARM_CPU(cs); @@ -910,29 +952,6 @@ static int kvm_arm_handle_dabt_nisv(CPUState *cs, uint= 64_t esr_iss, return -1; } =20 -int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) -{ - int ret =3D 0; - - switch (run->exit_reason) { - case KVM_EXIT_DEBUG: - if (kvm_arm_handle_debug(cs, &run->debug.arch)) { - ret =3D EXCP_DEBUG; - } /* otherwise return to guest */ - break; - case KVM_EXIT_ARM_NISV: - /* External DABT with no valid iss to decode */ - ret =3D kvm_arm_handle_dabt_nisv(cs, run->arm_nisv.esr_iss, - run->arm_nisv.fault_ipa); - break; - default: - qemu_log_mask(LOG_UNIMP, "%s: un-handled exit reason %d\n", - __func__, run->exit_reason); - break; - } - return ret; -} - bool kvm_arch_stop_on_emulation_error(CPUState *cs) { return true; @@ -943,17 +962,6 @@ int kvm_arch_process_async_events(CPUState *cs) return 0; } =20 -void kvm_arch_update_guest_debug(CPUState *cs, struct kvm_guest_debug *dbg) -{ - if (kvm_sw_breakpoints_active(cs)) { - dbg->control |=3D KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_SW_BP; - } - if (kvm_arm_hw_debug_active(cs)) { - dbg->control |=3D KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_HW; - kvm_arm_copy_hw_debug_data(&dbg->arch); - } -} - void kvm_arch_init_irq_routing(KVMState *s) { } @@ -1062,3 +1070,1737 @@ bool kvm_arch_cpu_check_are_resettable(void) void kvm_arch_accel_class_init(ObjectClass *oc) { } + +static bool have_guest_debug; + +/* + * Although the ARM implementation of hardware assisted debugging + * allows for different breakpoints per-core, the current GDB + * interface treats them as a global pool of registers (which seems to + * be the case for x86, ppc and s390). As a result we store one copy + * of registers which is used for all active cores. + * + * Write access is serialised by virtue of the GDB protocol which + * updates things. Read access (i.e. when the values are copied to the + * vCPU) is also gated by GDB's run control. + * + * This is not unreasonable as most of the time debugging kernels you + * never know which core will eventually execute your function. + */ + +typedef struct { + uint64_t bcr; + uint64_t bvr; +} HWBreakpoint; + +/* The watchpoint registers can cover more area than the requested + * watchpoint so we need to store the additional information + * somewhere. We also need to supply a CPUWatchpoint to the GDB stub + * when the watchpoint is hit. + */ +typedef struct { + uint64_t wcr; + uint64_t wvr; + CPUWatchpoint details; +} HWWatchpoint; + +/* Maximum and current break/watch point counts */ +int max_hw_bps, max_hw_wps; +GArray *hw_breakpoints, *hw_watchpoints; + +#define cur_hw_wps (hw_watchpoints->len) +#define cur_hw_bps (hw_breakpoints->len) +#define get_hw_bp(i) (&g_array_index(hw_breakpoints, HWBreakpoint, i)) +#define get_hw_wp(i) (&g_array_index(hw_watchpoints, HWWatchpoint, i)) + +/** + * kvm_arm_init_debug() - check for guest debug capabilities + * @cs: CPUState + * + * kvm_check_extension returns the number of debug registers we have + * or 0 if we have none. + * + */ +static void kvm_arm_init_debug(CPUState *cs) +{ + have_guest_debug =3D kvm_check_extension(cs->kvm_state, + KVM_CAP_SET_GUEST_DEBUG); + + max_hw_wps =3D kvm_check_extension(cs->kvm_state, KVM_CAP_GUEST_DEBUG_= HW_WPS); + hw_watchpoints =3D g_array_sized_new(true, true, + sizeof(HWWatchpoint), max_hw_wps); + + max_hw_bps =3D kvm_check_extension(cs->kvm_state, KVM_CAP_GUEST_DEBUG_= HW_BPS); + hw_breakpoints =3D g_array_sized_new(true, true, + sizeof(HWBreakpoint), max_hw_bps); + return; +} + +/** + * insert_hw_breakpoint() + * @addr: address of breakpoint + * + * See ARM ARM D2.9.1 for details but here we are only going to create + * simple un-linked breakpoints (i.e. we don't chain breakpoints + * together to match address and context or vmid). The hardware is + * capable of fancier matching but that will require exposing that + * fanciness to GDB's interface + * + * DBGBCR_EL1, Debug Breakpoint Control Registers + * + * 31 24 23 20 19 16 15 14 13 12 9 8 5 4 3 2 1 0 + * +------+------+-------+-----+----+------+-----+------+-----+---+ + * | RES0 | BT | LBN | SSC | HMC| RES0 | BAS | RES0 | PMC | E | + * +------+------+-------+-----+----+------+-----+------+-----+---+ + * + * BT: Breakpoint type (0 =3D unlinked address match) + * LBN: Linked BP number (0 =3D unused) + * SSC/HMC/PMC: Security, Higher and Priv access control (Table D-12) + * BAS: Byte Address Select (RES1 for AArch64) + * E: Enable bit + * + * DBGBVR_EL1, Debug Breakpoint Value Registers + * + * 63 53 52 49 48 2 1 0 + * +------+-----------+----------+-----+ + * | RESS | VA[52:49] | VA[48:2] | 0 0 | + * +------+-----------+----------+-----+ + * + * Depending on the addressing mode bits the top bits of the register + * are a sign extension of the highest applicable VA bit. Some + * versions of GDB don't do it correctly so we ensure they are correct + * here so future PC comparisons will work properly. + */ + +static int insert_hw_breakpoint(target_ulong addr) +{ + HWBreakpoint brk =3D { + .bcr =3D 0x1, /* BCR E=3D1, enable */ + .bvr =3D sextract64(addr, 0, 53) + }; + + if (cur_hw_bps >=3D max_hw_bps) { + return -ENOBUFS; + } + + brk.bcr =3D deposit32(brk.bcr, 1, 2, 0x3); /* PMC =3D 11 */ + brk.bcr =3D deposit32(brk.bcr, 5, 4, 0xf); /* BAS =3D RES1 */ + + g_array_append_val(hw_breakpoints, brk); + + return 0; +} + +/** + * delete_hw_breakpoint() + * @pc: address of breakpoint + * + * Delete a breakpoint and shuffle any above down + */ + +static int delete_hw_breakpoint(target_ulong pc) +{ + int i; + for (i =3D 0; i < hw_breakpoints->len; i++) { + HWBreakpoint *brk =3D get_hw_bp(i); + if (brk->bvr =3D=3D pc) { + g_array_remove_index(hw_breakpoints, i); + return 0; + } + } + return -ENOENT; +} + +/** + * insert_hw_watchpoint() + * @addr: address of watch point + * @len: size of area + * @type: type of watch point + * + * See ARM ARM D2.10. As with the breakpoints we can do some advanced + * stuff if we want to. The watch points can be linked with the break + * points above to make them context aware. However for simplicity + * currently we only deal with simple read/write watch points. + * + * D7.3.11 DBGWCR_EL1, Debug Watchpoint Control Registers + * + * 31 29 28 24 23 21 20 19 16 15 14 13 12 5 4 3 2 1 0 + * +------+-------+------+----+-----+-----+-----+-----+-----+-----+---+ + * | RES0 | MASK | RES0 | WT | LBN | SSC | HMC | BAS | LSC | PAC | E | + * +------+-------+------+----+-----+-----+-----+-----+-----+-----+---+ + * + * MASK: num bits addr mask (0=3Dnone,01/10=3Dres,11=3D3 bits (8 bytes)) + * WT: 0 - unlinked, 1 - linked (not currently used) + * LBN: Linked BP number (not currently used) + * SSC/HMC/PAC: Security, Higher and Priv access control (Table D2-11) + * BAS: Byte Address Select + * LSC: Load/Store control (01: load, 10: store, 11: both) + * E: Enable + * + * The bottom 2 bits of the value register are masked. Therefore to + * break on any sizes smaller than an unaligned word you need to set + * MASK=3D0, BAS=3Dbit per byte in question. For larger regions (^2) you + * need to ensure you mask the address as required and set BAS=3D0xff + */ + +static int insert_hw_watchpoint(target_ulong addr, + target_ulong len, int type) +{ + HWWatchpoint wp =3D { + .wcr =3D R_DBGWCR_E_MASK, /* E=3D1, enable */ + .wvr =3D addr & (~0x7ULL), + .details =3D { .vaddr =3D addr, .len =3D len } + }; + + if (cur_hw_wps >=3D max_hw_wps) { + return -ENOBUFS; + } + + /* + * HMC=3D0 SSC=3D0 PAC=3D3 will hit EL0 or EL1, any security state, + * valid whether EL3 is implemented or not + */ + wp.wcr =3D FIELD_DP64(wp.wcr, DBGWCR, PAC, 3); + + switch (type) { + case GDB_WATCHPOINT_READ: + wp.wcr =3D FIELD_DP64(wp.wcr, DBGWCR, LSC, 1); + wp.details.flags =3D BP_MEM_READ; + break; + case GDB_WATCHPOINT_WRITE: + wp.wcr =3D FIELD_DP64(wp.wcr, DBGWCR, LSC, 2); + wp.details.flags =3D BP_MEM_WRITE; + break; + case GDB_WATCHPOINT_ACCESS: + wp.wcr =3D FIELD_DP64(wp.wcr, DBGWCR, LSC, 3); + wp.details.flags =3D BP_MEM_ACCESS; + break; + default: + g_assert_not_reached(); + break; + } + if (len <=3D 8) { + /* we align the address and set the bits in BAS */ + int off =3D addr & 0x7; + int bas =3D (1 << len) - 1; + + wp.wcr =3D deposit32(wp.wcr, 5 + off, 8 - off, bas); + } else { + /* For ranges above 8 bytes we need to be a power of 2 */ + if (is_power_of_2(len)) { + int bits =3D ctz64(len); + + wp.wvr &=3D ~((1 << bits) - 1); + wp.wcr =3D FIELD_DP64(wp.wcr, DBGWCR, MASK, bits); + wp.wcr =3D FIELD_DP64(wp.wcr, DBGWCR, BAS, 0xff); + } else { + return -ENOBUFS; + } + } + + g_array_append_val(hw_watchpoints, wp); + return 0; +} + + +static bool check_watchpoint_in_range(int i, target_ulong addr) +{ + HWWatchpoint *wp =3D get_hw_wp(i); + uint64_t addr_top, addr_bottom =3D wp->wvr; + int bas =3D extract32(wp->wcr, 5, 8); + int mask =3D extract32(wp->wcr, 24, 4); + + if (mask) { + addr_top =3D addr_bottom + (1 << mask); + } else { + /* BAS must be contiguous but can offset against the base + * address in DBGWVR */ + addr_bottom =3D addr_bottom + ctz32(bas); + addr_top =3D addr_bottom + clo32(bas); + } + + if (addr >=3D addr_bottom && addr <=3D addr_top) { + return true; + } + + return false; +} + +/** + * delete_hw_watchpoint() + * @addr: address of breakpoint + * + * Delete a breakpoint and shuffle any above down + */ + +static int delete_hw_watchpoint(target_ulong addr, + target_ulong len, int type) +{ + int i; + for (i =3D 0; i < cur_hw_wps; i++) { + if (check_watchpoint_in_range(i, addr)) { + g_array_remove_index(hw_watchpoints, i); + return 0; + } + } + return -ENOENT; +} + + +int kvm_arch_insert_hw_breakpoint(target_ulong addr, + target_ulong len, int type) +{ + switch (type) { + case GDB_BREAKPOINT_HW: + return insert_hw_breakpoint(addr); + break; + case GDB_WATCHPOINT_READ: + case GDB_WATCHPOINT_WRITE: + case GDB_WATCHPOINT_ACCESS: + return insert_hw_watchpoint(addr, len, type); + default: + return -ENOSYS; + } +} + +int kvm_arch_remove_hw_breakpoint(target_ulong addr, + target_ulong len, int type) +{ + switch (type) { + case GDB_BREAKPOINT_HW: + return delete_hw_breakpoint(addr); + case GDB_WATCHPOINT_READ: + case GDB_WATCHPOINT_WRITE: + case GDB_WATCHPOINT_ACCESS: + return delete_hw_watchpoint(addr, len, type); + default: + return -ENOSYS; + } +} + + +void kvm_arch_remove_all_hw_breakpoints(void) +{ + if (cur_hw_wps > 0) { + g_array_remove_range(hw_watchpoints, 0, cur_hw_wps); + } + if (cur_hw_bps > 0) { + g_array_remove_range(hw_breakpoints, 0, cur_hw_bps); + } +} + +/** + * kvm_arm_copy_hw_debug_data: + * @ptr: kvm_guest_debug_arch structure + * + * Copy the architecture specific debug registers into the + * kvm_guest_debug ioctl structure. + */ +static void kvm_arm_copy_hw_debug_data(struct kvm_guest_debug_arch *ptr) +{ + int i; + memset(ptr, 0, sizeof(struct kvm_guest_debug_arch)); + + for (i =3D 0; i < max_hw_wps; i++) { + HWWatchpoint *wp =3D get_hw_wp(i); + ptr->dbg_wcr[i] =3D wp->wcr; + ptr->dbg_wvr[i] =3D wp->wvr; + } + for (i =3D 0; i < max_hw_bps; i++) { + HWBreakpoint *bp =3D get_hw_bp(i); + ptr->dbg_bcr[i] =3D bp->bcr; + ptr->dbg_bvr[i] =3D bp->bvr; + } +} + +/** + * kvm_arm_hw_debug_active: + * @cs: CPU State + * + * Return: TRUE if any hardware breakpoints in use. + */ +static bool kvm_arm_hw_debug_active(CPUState *cs) +{ + return ((cur_hw_wps > 0) || (cur_hw_bps > 0)); +} + +static bool find_hw_breakpoint(CPUState *cpu, target_ulong pc) +{ + int i; + + for (i =3D 0; i < cur_hw_bps; i++) { + HWBreakpoint *bp =3D get_hw_bp(i); + if (bp->bvr =3D=3D pc) { + return true; + } + } + return false; +} + +static CPUWatchpoint *find_hw_watchpoint(CPUState *cpu, target_ulong addr) +{ + int i; + + for (i =3D 0; i < cur_hw_wps; i++) { + if (check_watchpoint_in_range(i, addr)) { + return &get_hw_wp(i)->details; + } + } + return NULL; +} + +static bool kvm_arm_set_device_attr(CPUState *cs, struct kvm_device_attr *= attr, + const char *name) +{ + int err; + + err =3D kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, attr); + if (err !=3D 0) { + error_report("%s: KVM_HAS_DEVICE_ATTR: %s", name, strerror(-err)); + return false; + } + + err =3D kvm_vcpu_ioctl(cs, KVM_SET_DEVICE_ATTR, attr); + if (err !=3D 0) { + error_report("%s: KVM_SET_DEVICE_ATTR: %s", name, strerror(-err)); + return false; + } + + return true; +} + +void kvm_arm_pmu_init(CPUState *cs) +{ + struct kvm_device_attr attr =3D { + .group =3D KVM_ARM_VCPU_PMU_V3_CTRL, + .attr =3D KVM_ARM_VCPU_PMU_V3_INIT, + }; + + if (!ARM_CPU(cs)->has_pmu) { + return; + } + if (!kvm_arm_set_device_attr(cs, &attr, "PMU")) { + error_report("failed to init PMU"); + abort(); + } +} + +void kvm_arm_pmu_set_irq(CPUState *cs, int irq) +{ + struct kvm_device_attr attr =3D { + .group =3D KVM_ARM_VCPU_PMU_V3_CTRL, + .addr =3D (intptr_t)&irq, + .attr =3D KVM_ARM_VCPU_PMU_V3_IRQ, + }; + + if (!ARM_CPU(cs)->has_pmu) { + return; + } + if (!kvm_arm_set_device_attr(cs, &attr, "PMU")) { + error_report("failed to set irq for PMU"); + abort(); + } +} + +void kvm_arm_pvtime_init(CPUState *cs, uint64_t ipa) +{ + struct kvm_device_attr attr =3D { + .group =3D KVM_ARM_VCPU_PVTIME_CTRL, + .attr =3D KVM_ARM_VCPU_PVTIME_IPA, + .addr =3D (uint64_t)&ipa, + }; + + if (ARM_CPU(cs)->kvm_steal_time =3D=3D ON_OFF_AUTO_OFF) { + return; + } + if (!kvm_arm_set_device_attr(cs, &attr, "PVTIME IPA")) { + error_report("failed to init PVTIME IPA"); + abort(); + } +} + +static int read_sys_reg32(int fd, uint32_t *pret, uint64_t id) +{ + uint64_t ret; + struct kvm_one_reg idreg =3D { .id =3D id, .addr =3D (uintptr_t)&ret }; + int err; + + assert((id & KVM_REG_SIZE_MASK) =3D=3D KVM_REG_SIZE_U64); + err =3D ioctl(fd, KVM_GET_ONE_REG, &idreg); + if (err < 0) { + return -1; + } + *pret =3D ret; + return 0; +} + +static int read_sys_reg64(int fd, uint64_t *pret, uint64_t id) +{ + struct kvm_one_reg idreg =3D { .id =3D id, .addr =3D (uintptr_t)pret }; + + assert((id & KVM_REG_SIZE_MASK) =3D=3D KVM_REG_SIZE_U64); + return ioctl(fd, KVM_GET_ONE_REG, &idreg); +} + +static bool kvm_arm_pauth_supported(void) +{ + return (kvm_check_extension(kvm_state, KVM_CAP_ARM_PTRAUTH_ADDRESS) && + kvm_check_extension(kvm_state, KVM_CAP_ARM_PTRAUTH_GENERIC)); +} + +/** + * kvm_arm_get_host_cpu_features: + * @ahcf: ARMHostCPUClass to fill in + * + * Probe the capabilities of the host kernel's preferred CPU and fill + * in the ARMHostCPUClass struct accordingly. + * + * Returns true on success and false otherwise. + */ +static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) +{ + /* Identify the feature bits corresponding to the host CPU, and + * fill out the ARMHostCPUClass fields accordingly. To do this + * we have to create a scratch VM, create a single CPU inside it, + * and then query that CPU for the relevant ID registers. + */ + int fdarray[3]; + bool sve_supported; + bool pmu_supported =3D false; + uint64_t features =3D 0; + int err; + + /* Old kernels may not know about the PREFERRED_TARGET ioctl: however + * we know these will only support creating one kind of guest CPU, + * which is its preferred CPU type. Fortunately these old kernels + * support only a very limited number of CPUs. + */ + static const uint32_t cpus_to_try[] =3D { + KVM_ARM_TARGET_AEM_V8, + KVM_ARM_TARGET_FOUNDATION_V8, + KVM_ARM_TARGET_CORTEX_A57, + QEMU_KVM_ARM_TARGET_NONE + }; + /* + * target =3D -1 informs kvm_arm_create_scratch_host_vcpu() + * to use the preferred target + */ + struct kvm_vcpu_init init =3D { .target =3D -1, }; + + /* + * Ask for SVE if supported, so that we can query ID_AA64ZFR0, + * which is otherwise RAZ. + */ + sve_supported =3D kvm_arm_sve_supported(); + if (sve_supported) { + init.features[0] |=3D 1 << KVM_ARM_VCPU_SVE; + } + + /* + * Ask for Pointer Authentication if supported, so that we get + * the unsanitized field values for AA64ISAR1_EL1. + */ + if (kvm_arm_pauth_supported()) { + init.features[0] |=3D (1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS | + 1 << KVM_ARM_VCPU_PTRAUTH_GENERIC); + } + + if (kvm_arm_pmu_supported()) { + init.features[0] |=3D 1 << KVM_ARM_VCPU_PMU_V3; + pmu_supported =3D true; + } + + if (!kvm_arm_create_scratch_host_vcpu(cpus_to_try, fdarray, &init)) { + return false; + } + + ahcf->target =3D init.target; + ahcf->dtb_compatible =3D "arm,arm-v8"; + + err =3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64pfr0, + ARM64_SYS_REG(3, 0, 0, 4, 0)); + if (unlikely(err < 0)) { + /* + * Before v4.15, the kernel only exposed a limited number of system + * registers, not including any of the interesting AArch64 ID regs. + * For the most part we could leave these fields as zero with mini= mal + * effect, since this does not affect the values seen by the guest. + * + * However, it could cause problems down the line for QEMU, + * so provide a minimal v8.0 default. + * + * ??? Could read MIDR and use knowledge from cpu64.c. + * ??? Could map a page of memory into our temp guest and + * run the tiniest of hand-crafted kernels to extract + * the values seen by the guest. + * ??? Either of these sounds like too much effort just + * to work around running a modern host kernel. + */ + ahcf->isar.id_aa64pfr0 =3D 0x00000011; /* EL1&0, AArch64 only */ + err =3D 0; + } else { + err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64pfr1, + ARM64_SYS_REG(3, 0, 0, 4, 1)); + err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64smfr0, + ARM64_SYS_REG(3, 0, 0, 4, 5)); + err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64dfr0, + ARM64_SYS_REG(3, 0, 0, 5, 0)); + err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64dfr1, + ARM64_SYS_REG(3, 0, 0, 5, 1)); + err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64isar0, + ARM64_SYS_REG(3, 0, 0, 6, 0)); + err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64isar1, + ARM64_SYS_REG(3, 0, 0, 6, 1)); + err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr0, + ARM64_SYS_REG(3, 0, 0, 7, 0)); + err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr1, + ARM64_SYS_REG(3, 0, 0, 7, 1)); + err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr2, + ARM64_SYS_REG(3, 0, 0, 7, 2)); + + /* + * Note that if AArch32 support is not present in the host, + * the AArch32 sysregs are present to be read, but will + * return UNKNOWN values. This is neither better nor worse + * than skipping the reads and leaving 0, as we must avoid + * considering the values in every case. + */ + err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr0, + ARM64_SYS_REG(3, 0, 0, 1, 0)); + err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr1, + ARM64_SYS_REG(3, 0, 0, 1, 1)); + err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_dfr0, + ARM64_SYS_REG(3, 0, 0, 1, 2)); + err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr0, + ARM64_SYS_REG(3, 0, 0, 1, 4)); + err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr1, + ARM64_SYS_REG(3, 0, 0, 1, 5)); + err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr2, + ARM64_SYS_REG(3, 0, 0, 1, 6)); + err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr3, + ARM64_SYS_REG(3, 0, 0, 1, 7)); + err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_isar0, + ARM64_SYS_REG(3, 0, 0, 2, 0)); + err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_isar1, + ARM64_SYS_REG(3, 0, 0, 2, 1)); + err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_isar2, + ARM64_SYS_REG(3, 0, 0, 2, 2)); + err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_isar3, + ARM64_SYS_REG(3, 0, 0, 2, 3)); + err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_isar4, + ARM64_SYS_REG(3, 0, 0, 2, 4)); + err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_isar5, + ARM64_SYS_REG(3, 0, 0, 2, 5)); + err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr4, + ARM64_SYS_REG(3, 0, 0, 2, 6)); + err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_isar6, + ARM64_SYS_REG(3, 0, 0, 2, 7)); + + err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.mvfr0, + ARM64_SYS_REG(3, 0, 0, 3, 0)); + err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.mvfr1, + ARM64_SYS_REG(3, 0, 0, 3, 1)); + err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.mvfr2, + ARM64_SYS_REG(3, 0, 0, 3, 2)); + err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr2, + ARM64_SYS_REG(3, 0, 0, 3, 4)); + err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_dfr1, + ARM64_SYS_REG(3, 0, 0, 3, 5)); + err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr5, + ARM64_SYS_REG(3, 0, 0, 3, 6)); + + /* + * DBGDIDR is a bit complicated because the kernel doesn't + * provide an accessor for it in 64-bit mode, which is what this + * scratch VM is in, and there's no architected "64-bit sysreg + * which reads the same as the 32-bit register" the way there is + * for other ID registers. Instead we synthesize a value from the + * AArch64 ID_AA64DFR0, the same way the kernel code in + * arch/arm64/kvm/sys_regs.c:trap_dbgidr() does. + * We only do this if the CPU supports AArch32 at EL1. + */ + if (FIELD_EX32(ahcf->isar.id_aa64pfr0, ID_AA64PFR0, EL1) >=3D 2) { + int wrps =3D FIELD_EX64(ahcf->isar.id_aa64dfr0, ID_AA64DFR0, W= RPS); + int brps =3D FIELD_EX64(ahcf->isar.id_aa64dfr0, ID_AA64DFR0, B= RPS); + int ctx_cmps =3D + FIELD_EX64(ahcf->isar.id_aa64dfr0, ID_AA64DFR0, CTX_CMPS); + int version =3D 6; /* ARMv8 debug architecture */ + bool has_el3 =3D + !!FIELD_EX32(ahcf->isar.id_aa64pfr0, ID_AA64PFR0, EL3); + uint32_t dbgdidr =3D 0; + + dbgdidr =3D FIELD_DP32(dbgdidr, DBGDIDR, WRPS, wrps); + dbgdidr =3D FIELD_DP32(dbgdidr, DBGDIDR, BRPS, brps); + dbgdidr =3D FIELD_DP32(dbgdidr, DBGDIDR, CTX_CMPS, ctx_cmps); + dbgdidr =3D FIELD_DP32(dbgdidr, DBGDIDR, VERSION, version); + dbgdidr =3D FIELD_DP32(dbgdidr, DBGDIDR, NSUHD_IMP, has_el3); + dbgdidr =3D FIELD_DP32(dbgdidr, DBGDIDR, SE_IMP, has_el3); + dbgdidr |=3D (1 << 15); /* RES1 bit */ + ahcf->isar.dbgdidr =3D dbgdidr; + } + + if (pmu_supported) { + /* PMCR_EL0 is only accessible if the vCPU has feature PMU_V3 = */ + err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.reset_pmcr_el0, + ARM64_SYS_REG(3, 3, 9, 12, 0)); + } + + if (sve_supported) { + /* + * There is a range of kernels between kernel commit 73433762f= cae + * and f81cb2c3ad41 which have a bug where the kernel doesn't + * expose SYS_ID_AA64ZFR0_EL1 via the ONE_REG API unless the V= M has + * enabled SVE support, which resulted in an error rather than= RAZ. + * So only read the register if we set KVM_ARM_VCPU_SVE above. + */ + err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64zfr0, + ARM64_SYS_REG(3, 0, 0, 4, 4)); + } + } + + kvm_arm_destroy_scratch_host_vcpu(fdarray); + + if (err < 0) { + return false; + } + + /* + * We can assume any KVM supporting CPU is at least a v8 + * with VFPv4+Neon; this in turn implies most of the other + * feature bits. + */ + features |=3D 1ULL << ARM_FEATURE_V8; + features |=3D 1ULL << ARM_FEATURE_NEON; + features |=3D 1ULL << ARM_FEATURE_AARCH64; + features |=3D 1ULL << ARM_FEATURE_PMU; + features |=3D 1ULL << ARM_FEATURE_GENERIC_TIMER; + + ahcf->features =3D features; + + return true; +} + +void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) +{ + CPUARMState *env =3D &cpu->env; + + if (!arm_host_cpu_features.dtb_compatible) { + if (!kvm_enabled() || + !kvm_arm_get_host_cpu_features(&arm_host_cpu_features)) { + /* We can't report this error yet, so flag that we need to + * in arm_cpu_realizefn(). + */ + cpu->kvm_target =3D QEMU_KVM_ARM_TARGET_NONE; + cpu->host_cpu_probe_failed =3D true; + return; + } + } + + cpu->kvm_target =3D arm_host_cpu_features.target; + cpu->dtb_compatible =3D arm_host_cpu_features.dtb_compatible; + cpu->isar =3D arm_host_cpu_features.isar; + env->features =3D arm_host_cpu_features.features; +} + +/** + * kvm_arm_steal_time_supported: + * + * Returns: true if KVM can enable steal time reporting + * and false otherwise. + */ +static bool kvm_arm_steal_time_supported(void) +{ + return kvm_check_extension(kvm_state, KVM_CAP_STEAL_TIME); +} + +void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp) +{ + bool has_steal_time =3D kvm_arm_steal_time_supported(); + + if (cpu->kvm_steal_time =3D=3D ON_OFF_AUTO_AUTO) { + if (!has_steal_time || !arm_feature(&cpu->env, ARM_FEATURE_AARCH64= )) { + cpu->kvm_steal_time =3D ON_OFF_AUTO_OFF; + } else { + cpu->kvm_steal_time =3D ON_OFF_AUTO_ON; + } + } else if (cpu->kvm_steal_time =3D=3D ON_OFF_AUTO_ON) { + if (!has_steal_time) { + error_setg(errp, "'kvm-steal-time' cannot be enabled " + "on this host"); + return; + } else if (!arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { + /* + * DEN0057A chapter 2 says "This specification only covers + * systems in which the Execution state of the hypervisor + * as well as EL1 of virtual machines is AArch64.". And, + * to ensure that, the smc/hvc calls are only specified as + * smc64/hvc64. + */ + error_setg(errp, "'kvm-steal-time' cannot be enabled " + "for AArch32 guests"); + return; + } + } +} + +bool kvm_arm_aarch32_supported(void) +{ + return kvm_check_extension(kvm_state, KVM_CAP_ARM_EL1_32BIT); +} + +bool kvm_arm_sve_supported(void) +{ + return kvm_check_extension(kvm_state, KVM_CAP_ARM_SVE); +} + +QEMU_BUILD_BUG_ON(KVM_ARM64_SVE_VQ_MIN !=3D 1); + +uint32_t kvm_arm_sve_get_vls(CPUState *cs) +{ + /* Only call this function if kvm_arm_sve_supported() returns true. */ + static uint64_t vls[KVM_ARM64_SVE_VLS_WORDS]; + static bool probed; + uint32_t vq =3D 0; + int i; + + /* + * KVM ensures all host CPUs support the same set of vector lengths. + * So we only need to create the scratch VCPUs once and then cache + * the results. + */ + if (!probed) { + struct kvm_vcpu_init init =3D { + .target =3D -1, + .features[0] =3D (1 << KVM_ARM_VCPU_SVE), + }; + struct kvm_one_reg reg =3D { + .id =3D KVM_REG_ARM64_SVE_VLS, + .addr =3D (uint64_t)&vls[0], + }; + int fdarray[3], ret; + + probed =3D true; + + if (!kvm_arm_create_scratch_host_vcpu(NULL, fdarray, &init)) { + error_report("failed to create scratch VCPU with SVE enabled"); + abort(); + } + ret =3D ioctl(fdarray[2], KVM_GET_ONE_REG, ®); + kvm_arm_destroy_scratch_host_vcpu(fdarray); + if (ret) { + error_report("failed to get KVM_REG_ARM64_SVE_VLS: %s", + strerror(errno)); + abort(); + } + + for (i =3D KVM_ARM64_SVE_VLS_WORDS - 1; i >=3D 0; --i) { + if (vls[i]) { + vq =3D 64 - clz64(vls[i]) + i * 64; + break; + } + } + if (vq > ARM_MAX_VQ) { + warn_report("KVM supports vector lengths larger than " + "QEMU can enable"); + vls[0] &=3D MAKE_64BIT_MASK(0, ARM_MAX_VQ); + } + } + + return vls[0]; +} + +static int kvm_arm_sve_set_vls(CPUState *cs) +{ + ARMCPU *cpu =3D ARM_CPU(cs); + uint64_t vls[KVM_ARM64_SVE_VLS_WORDS] =3D { cpu->sve_vq.map }; + struct kvm_one_reg reg =3D { + .id =3D KVM_REG_ARM64_SVE_VLS, + .addr =3D (uint64_t)&vls[0], + }; + + assert(cpu->sve_max_vq <=3D KVM_ARM64_SVE_VQ_MAX); + + return kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); +} + +#define ARM_CPU_ID_MPIDR 3, 0, 0, 0, 5 + +int kvm_arch_init_vcpu(CPUState *cs) +{ + int ret; + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; + uint64_t psciver; + + if (cpu->kvm_target =3D=3D QEMU_KVM_ARM_TARGET_NONE || + !object_dynamic_cast(OBJECT(cpu), TYPE_AARCH64_CPU)) { + error_report("KVM is not supported for this guest CPU type"); + return -EINVAL; + } + + qemu_add_vm_change_state_handler(kvm_arm_vm_state_change, cs); + + /* Determine init features for this CPU */ + memset(cpu->kvm_init_features, 0, sizeof(cpu->kvm_init_features)); + if (cs->start_powered_off) { + cpu->kvm_init_features[0] |=3D 1 << KVM_ARM_VCPU_POWER_OFF; + } + if (kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PSCI_0_2)) { + cpu->psci_version =3D QEMU_PSCI_VERSION_0_2; + cpu->kvm_init_features[0] |=3D 1 << KVM_ARM_VCPU_PSCI_0_2; + } + if (!arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { + cpu->kvm_init_features[0] |=3D 1 << KVM_ARM_VCPU_EL1_32BIT; + } + if (!kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PMU_V3)) { + cpu->has_pmu =3D false; + } + if (cpu->has_pmu) { + cpu->kvm_init_features[0] |=3D 1 << KVM_ARM_VCPU_PMU_V3; + } else { + env->features &=3D ~(1ULL << ARM_FEATURE_PMU); + } + if (cpu_isar_feature(aa64_sve, cpu)) { + assert(kvm_arm_sve_supported()); + cpu->kvm_init_features[0] |=3D 1 << KVM_ARM_VCPU_SVE; + } + if (cpu_isar_feature(aa64_pauth, cpu)) { + cpu->kvm_init_features[0] |=3D (1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS | + 1 << KVM_ARM_VCPU_PTRAUTH_GENERIC); + } + + /* Do KVM_ARM_VCPU_INIT ioctl */ + ret =3D kvm_arm_vcpu_init(cs); + if (ret) { + return ret; + } + + if (cpu_isar_feature(aa64_sve, cpu)) { + ret =3D kvm_arm_sve_set_vls(cs); + if (ret) { + return ret; + } + ret =3D kvm_arm_vcpu_finalize(cs, KVM_ARM_VCPU_SVE); + if (ret) { + return ret; + } + } + + /* + * KVM reports the exact PSCI version it is implementing via a + * special sysreg. If it is present, use its contents to determine + * what to report to the guest in the dtb (it is the PSCI version, + * in the same 15-bits major 16-bits minor format that PSCI_VERSION + * returns). + */ + if (!kvm_get_one_reg(cs, KVM_REG_ARM_PSCI_VERSION, &psciver)) { + cpu->psci_version =3D psciver; + } + + /* + * When KVM is in use, PSCI is emulated in-kernel and not by qemu. + * Currently KVM has its own idea about MPIDR assignment, so we + * override our defaults with what we get from KVM. + */ + ret =3D kvm_get_one_reg(cs, ARM64_SYS_REG(ARM_CPU_ID_MPIDR), + &cpu->mpidr_el1); + if (ret) { + return ret; + } + + kvm_arm_init_debug(cs); + + /* Check whether user space can specify guest syndrome value */ + kvm_arm_init_serror_injection(cs); + + return kvm_arm_init_cpreg_list(cpu); +} + +int kvm_arch_destroy_vcpu(CPUState *cs) +{ + return 0; +} + +/* Callers must hold the iothread mutex lock */ +static void kvm_inject_arm_sea(CPUState *c) +{ + ARMCPU *cpu =3D ARM_CPU(c); + CPUARMState *env =3D &cpu->env; + uint32_t esr; + bool same_el; + + c->exception_index =3D EXCP_DATA_ABORT; + env->exception.target_el =3D 1; + + /* + * Set the DFSC to synchronous external abort and set FnV to not valid, + * this will tell guest the FAR_ELx is UNKNOWN for this abort. + */ + same_el =3D arm_current_el(env) =3D=3D env->exception.target_el; + esr =3D syn_data_abort_no_iss(same_el, 1, 0, 0, 0, 0, 0x10); + + env->exception.syndrome =3D esr; + + arm_cpu_do_interrupt(c); +} + +#define AARCH64_CORE_REG(x) (KVM_REG_ARM64 | KVM_REG_SIZE_U64 | \ + KVM_REG_ARM_CORE | KVM_REG_ARM_CORE_REG(x)) + +#define AARCH64_SIMD_CORE_REG(x) (KVM_REG_ARM64 | KVM_REG_SIZE_U128 | \ + KVM_REG_ARM_CORE | KVM_REG_ARM_CORE_REG(x)) + +#define AARCH64_SIMD_CTRL_REG(x) (KVM_REG_ARM64 | KVM_REG_SIZE_U32 | \ + KVM_REG_ARM_CORE | KVM_REG_ARM_CORE_REG(x)) + +static int kvm_arch_put_fpsimd(CPUState *cs) +{ + CPUARMState *env =3D &ARM_CPU(cs)->env; + struct kvm_one_reg reg; + int i, ret; + + for (i =3D 0; i < 32; i++) { + uint64_t *q =3D aa64_vfp_qreg(env, i); +#if HOST_BIG_ENDIAN + uint64_t fp_val[2] =3D { q[1], q[0] }; + reg.addr =3D (uintptr_t)fp_val; +#else + reg.addr =3D (uintptr_t)q; +#endif + reg.id =3D AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); + ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + } + + return 0; +} + +/* + * KVM SVE registers come in slices where ZREGs have a slice size of 2048 = bits + * and PREGS and the FFR have a slice size of 256 bits. However we simply = hard + * code the slice index to zero for now as it's unlikely we'll need more t= han + * one slice for quite some time. + */ +static int kvm_arch_put_sve(CPUState *cs) +{ + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; + uint64_t tmp[ARM_MAX_VQ * 2]; + uint64_t *r; + struct kvm_one_reg reg; + int n, ret; + + for (n =3D 0; n < KVM_ARM64_SVE_NUM_ZREGS; ++n) { + r =3D sve_bswap64(tmp, &env->vfp.zregs[n].d[0], cpu->sve_max_vq * = 2); + reg.addr =3D (uintptr_t)r; + reg.id =3D KVM_REG_ARM64_SVE_ZREG(n, 0); + ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + } + + for (n =3D 0; n < KVM_ARM64_SVE_NUM_PREGS; ++n) { + r =3D sve_bswap64(tmp, r =3D &env->vfp.pregs[n].p[0], + DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); + reg.addr =3D (uintptr_t)r; + reg.id =3D KVM_REG_ARM64_SVE_PREG(n, 0); + ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + } + + r =3D sve_bswap64(tmp, &env->vfp.pregs[FFR_PRED_NUM].p[0], + DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); + reg.addr =3D (uintptr_t)r; + reg.id =3D KVM_REG_ARM64_SVE_FFR(0); + ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + + return 0; +} + +int kvm_arch_put_registers(CPUState *cs, int level) +{ + struct kvm_one_reg reg; + uint64_t val; + uint32_t fpr; + int i, ret; + unsigned int el; + + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; + + /* If we are in AArch32 mode then we need to copy the AArch32 regs to = the + * AArch64 registers before pushing them out to 64-bit KVM. + */ + if (!is_a64(env)) { + aarch64_sync_32_to_64(env); + } + + for (i =3D 0; i < 31; i++) { + reg.id =3D AARCH64_CORE_REG(regs.regs[i]); + reg.addr =3D (uintptr_t) &env->xregs[i]; + ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + } + + /* KVM puts SP_EL0 in regs.sp and SP_EL1 in regs.sp_el1. On the + * QEMU side we keep the current SP in xregs[31] as well. + */ + aarch64_save_sp(env, 1); + + reg.id =3D AARCH64_CORE_REG(regs.sp); + reg.addr =3D (uintptr_t) &env->sp_el[0]; + ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + + reg.id =3D AARCH64_CORE_REG(sp_el1); + reg.addr =3D (uintptr_t) &env->sp_el[1]; + ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + + /* Note that KVM thinks pstate is 64 bit but we use a uint32_t */ + if (is_a64(env)) { + val =3D pstate_read(env); + } else { + val =3D cpsr_read(env); + } + reg.id =3D AARCH64_CORE_REG(regs.pstate); + reg.addr =3D (uintptr_t) &val; + ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + + reg.id =3D AARCH64_CORE_REG(regs.pc); + reg.addr =3D (uintptr_t) &env->pc; + ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + + reg.id =3D AARCH64_CORE_REG(elr_el1); + reg.addr =3D (uintptr_t) &env->elr_el[1]; + ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + + /* Saved Program State Registers + * + * Before we restore from the banked_spsr[] array we need to + * ensure that any modifications to env->spsr are correctly + * reflected in the banks. + */ + el =3D arm_current_el(env); + if (el > 0 && !is_a64(env)) { + i =3D bank_number(env->uncached_cpsr & CPSR_M); + env->banked_spsr[i] =3D env->spsr; + } + + /* KVM 0-4 map to QEMU banks 1-5 */ + for (i =3D 0; i < KVM_NR_SPSR; i++) { + reg.id =3D AARCH64_CORE_REG(spsr[i]); + reg.addr =3D (uintptr_t) &env->banked_spsr[i + 1]; + ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + } + + if (cpu_isar_feature(aa64_sve, cpu)) { + ret =3D kvm_arch_put_sve(cs); + } else { + ret =3D kvm_arch_put_fpsimd(cs); + } + if (ret) { + return ret; + } + + reg.addr =3D (uintptr_t)(&fpr); + fpr =3D vfp_get_fpsr(env); + reg.id =3D AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); + ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + + reg.addr =3D (uintptr_t)(&fpr); + fpr =3D vfp_get_fpcr(env); + reg.id =3D AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); + ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + + write_cpustate_to_list(cpu, true); + + if (!write_list_to_kvmstate(cpu, level)) { + return -EINVAL; + } + + /* + * Setting VCPU events should be triggered after syncing the registers + * to avoid overwriting potential changes made by KVM upon calling + * KVM_SET_VCPU_EVENTS ioctl + */ + ret =3D kvm_put_vcpu_events(cpu); + if (ret) { + return ret; + } + + kvm_arm_sync_mpstate_to_kvm(cpu); + + return ret; +} + +static int kvm_arch_get_fpsimd(CPUState *cs) +{ + CPUARMState *env =3D &ARM_CPU(cs)->env; + struct kvm_one_reg reg; + int i, ret; + + for (i =3D 0; i < 32; i++) { + uint64_t *q =3D aa64_vfp_qreg(env, i); + reg.id =3D AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); + reg.addr =3D (uintptr_t)q; + ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } else { +#if HOST_BIG_ENDIAN + uint64_t t; + t =3D q[0], q[0] =3D q[1], q[1] =3D t; +#endif + } + } + + return 0; +} + +/* + * KVM SVE registers come in slices where ZREGs have a slice size of 2048 = bits + * and PREGS and the FFR have a slice size of 256 bits. However we simply = hard + * code the slice index to zero for now as it's unlikely we'll need more t= han + * one slice for quite some time. + */ +static int kvm_arch_get_sve(CPUState *cs) +{ + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; + struct kvm_one_reg reg; + uint64_t *r; + int n, ret; + + for (n =3D 0; n < KVM_ARM64_SVE_NUM_ZREGS; ++n) { + r =3D &env->vfp.zregs[n].d[0]; + reg.addr =3D (uintptr_t)r; + reg.id =3D KVM_REG_ARM64_SVE_ZREG(n, 0); + ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + sve_bswap64(r, r, cpu->sve_max_vq * 2); + } + + for (n =3D 0; n < KVM_ARM64_SVE_NUM_PREGS; ++n) { + r =3D &env->vfp.pregs[n].p[0]; + reg.addr =3D (uintptr_t)r; + reg.id =3D KVM_REG_ARM64_SVE_PREG(n, 0); + ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + sve_bswap64(r, r, DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); + } + + r =3D &env->vfp.pregs[FFR_PRED_NUM].p[0]; + reg.addr =3D (uintptr_t)r; + reg.id =3D KVM_REG_ARM64_SVE_FFR(0); + ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + sve_bswap64(r, r, DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); + + return 0; +} + +int kvm_arch_get_registers(CPUState *cs) +{ + struct kvm_one_reg reg; + uint64_t val; + unsigned int el; + uint32_t fpr; + int i, ret; + + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; + + for (i =3D 0; i < 31; i++) { + reg.id =3D AARCH64_CORE_REG(regs.regs[i]); + reg.addr =3D (uintptr_t) &env->xregs[i]; + ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + } + + reg.id =3D AARCH64_CORE_REG(regs.sp); + reg.addr =3D (uintptr_t) &env->sp_el[0]; + ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + + reg.id =3D AARCH64_CORE_REG(sp_el1); + reg.addr =3D (uintptr_t) &env->sp_el[1]; + ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + + reg.id =3D AARCH64_CORE_REG(regs.pstate); + reg.addr =3D (uintptr_t) &val; + ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + + env->aarch64 =3D ((val & PSTATE_nRW) =3D=3D 0); + if (is_a64(env)) { + pstate_write(env, val); + } else { + cpsr_write(env, val, 0xffffffff, CPSRWriteRaw); + } + + /* KVM puts SP_EL0 in regs.sp and SP_EL1 in regs.sp_el1. On the + * QEMU side we keep the current SP in xregs[31] as well. + */ + aarch64_restore_sp(env, 1); + + reg.id =3D AARCH64_CORE_REG(regs.pc); + reg.addr =3D (uintptr_t) &env->pc; + ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + + /* If we are in AArch32 mode then we need to sync the AArch32 regs wit= h the + * incoming AArch64 regs received from 64-bit KVM. + * We must perform this after all of the registers have been acquired = from + * the kernel. + */ + if (!is_a64(env)) { + aarch64_sync_64_to_32(env); + } + + reg.id =3D AARCH64_CORE_REG(elr_el1); + reg.addr =3D (uintptr_t) &env->elr_el[1]; + ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + + /* Fetch the SPSR registers + * + * KVM SPSRs 0-4 map to QEMU banks 1-5 + */ + for (i =3D 0; i < KVM_NR_SPSR; i++) { + reg.id =3D AARCH64_CORE_REG(spsr[i]); + reg.addr =3D (uintptr_t) &env->banked_spsr[i + 1]; + ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + } + + el =3D arm_current_el(env); + if (el > 0 && !is_a64(env)) { + i =3D bank_number(env->uncached_cpsr & CPSR_M); + env->spsr =3D env->banked_spsr[i]; + } + + if (cpu_isar_feature(aa64_sve, cpu)) { + ret =3D kvm_arch_get_sve(cs); + } else { + ret =3D kvm_arch_get_fpsimd(cs); + } + if (ret) { + return ret; + } + + reg.addr =3D (uintptr_t)(&fpr); + reg.id =3D AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); + ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + vfp_set_fpsr(env, fpr); + + reg.addr =3D (uintptr_t)(&fpr); + reg.id =3D AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); + ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + vfp_set_fpcr(env, fpr); + + ret =3D kvm_get_vcpu_events(cpu); + if (ret) { + return ret; + } + + if (!write_kvmstate_to_list(cpu)) { + return -EINVAL; + } + /* Note that it's OK to have registers which aren't in CPUState, + * so we can ignore a failure return here. + */ + write_list_to_cpustate(cpu); + + kvm_arm_sync_mpstate_to_qemu(cpu); + + /* TODO: other registers */ + return ret; +} + +void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, void *addr) +{ + ram_addr_t ram_addr; + hwaddr paddr; + + assert(code =3D=3D BUS_MCEERR_AR || code =3D=3D BUS_MCEERR_AO); + + if (acpi_ghes_present() && addr) { + ram_addr =3D qemu_ram_addr_from_host(addr); + if (ram_addr !=3D RAM_ADDR_INVALID && + kvm_physical_memory_addr_from_host(c->kvm_state, addr, &paddr)= ) { + kvm_hwpoison_page_add(ram_addr); + /* + * If this is a BUS_MCEERR_AR, we know we have been called + * synchronously from the vCPU thread, so we can easily + * synchronize the state and inject an error. + * + * TODO: we currently don't tell the guest at all about + * BUS_MCEERR_AO. In that case we might either be being + * called synchronously from the vCPU thread, or a bit + * later from the main thread, so doing the injection of + * the error would be more complicated. + */ + if (code =3D=3D BUS_MCEERR_AR) { + kvm_cpu_synchronize_state(c); + if (!acpi_ghes_record_errors(ACPI_HEST_SRC_ID_SEA, paddr))= { + kvm_inject_arm_sea(c); + } else { + error_report("failed to record the error"); + abort(); + } + } + return; + } + if (code =3D=3D BUS_MCEERR_AO) { + error_report("Hardware memory error at addr %p for memory used= by " + "QEMU itself instead of guest system!", addr); + } + } + + if (code =3D=3D BUS_MCEERR_AR) { + error_report("Hardware memory error!"); + exit(1); + } +} + +/* C6.6.29 BRK instruction */ +static const uint32_t brk_insn =3D 0xd4200000; + +int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *= bp) +{ + if (have_guest_debug) { + if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4,= 0) || + cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk_insn, 4, 1)) { + return -EINVAL; + } + return 0; + } else { + error_report("guest debug not supported on this kernel"); + return -EINVAL; + } +} + +int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *= bp) +{ + static uint32_t brk; + + if (have_guest_debug) { + if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk, 4, 0) || + brk !=3D brk_insn || + cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4,= 1)) { + return -EINVAL; + } + return 0; + } else { + error_report("guest debug not supported on this kernel"); + return -EINVAL; + } +} + +/** + * kvm_arm_handle_debug: + * @cs: CPUState + * @debug_exit: debug part of the KVM exit structure + * + * Returns: TRUE if the debug exception was handled. + * + * See v8 ARM ARM D7.2.27 ESR_ELx, Exception Syndrome Register + * To minimise translating between kernel and user-space the kernel + * ABI just provides user-space with the full exception syndrome + * register value to be decoded in QEMU. + */ +static bool kvm_arm_handle_debug(CPUState *cs, + struct kvm_debug_exit_arch *debug_exit) +{ + int hsr_ec =3D syn_get_ec(debug_exit->hsr); + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; + + /* Ensure PC is synchronised */ + kvm_cpu_synchronize_state(cs); + + switch (hsr_ec) { + case EC_SOFTWARESTEP: + if (cs->singlestep_enabled) { + return true; + } else { + /* + * The kernel should have suppressed the guest's ability to + * single step at this point so something has gone wrong. + */ + error_report("%s: guest single-step while debugging unsupporte= d" + " (%"PRIx64", %"PRIx32")", + __func__, env->pc, debug_exit->hsr); + return false; + } + break; + case EC_AA64_BKPT: + if (kvm_find_sw_breakpoint(cs, env->pc)) { + return true; + } + break; + case EC_BREAKPOINT: + if (find_hw_breakpoint(cs, env->pc)) { + return true; + } + break; + case EC_WATCHPOINT: + { + CPUWatchpoint *wp =3D find_hw_watchpoint(cs, debug_exit->far); + if (wp) { + cs->watchpoint_hit =3D wp; + return true; + } + break; + } + default: + error_report("%s: unhandled debug exit (%"PRIx32", %"PRIx64")", + __func__, debug_exit->hsr, env->pc); + } + + /* If we are not handling the debug exception it must belong to + * the guest. Let's re-use the existing TCG interrupt code to set + * everything up properly. + */ + cs->exception_index =3D EXCP_BKPT; + env->exception.syndrome =3D debug_exit->hsr; + env->exception.vaddress =3D debug_exit->far; + env->exception.target_el =3D 1; + qemu_mutex_lock_iothread(); + arm_cpu_do_interrupt(cs); + qemu_mutex_unlock_iothread(); + + return false; +} + +#define ARM64_REG_ESR_EL1 ARM64_SYS_REG(3, 0, 5, 2, 0) +#define ARM64_REG_TCR_EL1 ARM64_SYS_REG(3, 0, 2, 0, 2) + +/* + * ESR_EL1 + * ISS encoding + * AARCH64: DFSC, bits [5:0] + * AARCH32: + * TTBCR.EAE =3D=3D 0 + * FS[4] - DFSR[10] + * FS[3:0] - DFSR[3:0] + * TTBCR.EAE =3D=3D 1 + * FS, bits [5:0] + */ +#define ESR_DFSC(aarch64, lpae, v) \ + ((aarch64 || (lpae)) ? ((v) & 0x3F) \ + : (((v) >> 6) | ((v) & 0x1F))) + +#define ESR_DFSC_EXTABT(aarch64, lpae) \ + ((aarch64) ? 0x10 : (lpae) ? 0x10 : 0x8) + +/** + * kvm_arm_verify_ext_dabt_pending: + * @cs: CPUState + * + * Verify the fault status code wrt the Ext DABT injection + * + * Returns: true if the fault status code is as expected, false otherwise + */ +static bool kvm_arm_verify_ext_dabt_pending(CPUState *cs) +{ + uint64_t dfsr_val; + + if (!kvm_get_one_reg(cs, ARM64_REG_ESR_EL1, &dfsr_val)) { + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; + int aarch64_mode =3D arm_feature(env, ARM_FEATURE_AARCH64); + int lpae =3D 0; + + if (!aarch64_mode) { + uint64_t ttbcr; + + if (!kvm_get_one_reg(cs, ARM64_REG_TCR_EL1, &ttbcr)) { + lpae =3D arm_feature(env, ARM_FEATURE_LPAE) + && (ttbcr & TTBCR_EAE); + } + } + /* + * The verification here is based on the DFSC bits + * of the ESR_EL1 reg only + */ + return (ESR_DFSC(aarch64_mode, lpae, dfsr_val) =3D=3D + ESR_DFSC_EXTABT(aarch64_mode, lpae)); + } + return false; +} + +int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) +{ + int ret =3D 0; + + switch (run->exit_reason) { + case KVM_EXIT_DEBUG: + if (kvm_arm_handle_debug(cs, &run->debug.arch)) { + ret =3D EXCP_DEBUG; + } /* otherwise return to guest */ + break; + case KVM_EXIT_ARM_NISV: + /* External DABT with no valid iss to decode */ + ret =3D kvm_arm_handle_dabt_nisv(cs, run->arm_nisv.esr_iss, + run->arm_nisv.fault_ipa); + break; + default: + qemu_log_mask(LOG_UNIMP, "%s: un-handled exit reason %d\n", + __func__, run->exit_reason); + break; + } + return ret; +} + +void kvm_arch_update_guest_debug(CPUState *cs, struct kvm_guest_debug *dbg) +{ + if (kvm_sw_breakpoints_active(cs)) { + dbg->control |=3D KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_SW_BP; + } + if (kvm_arm_hw_debug_active(cs)) { + dbg->control |=3D KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_HW; + kvm_arm_copy_hw_debug_data(&dbg->arch); + } +} + +void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run) +{ + ARMCPU *cpu =3D ARM_CPU(cs); + CPUARMState *env =3D &cpu->env; + + if (unlikely(env->ext_dabt_raised)) { + /* + * Verifying that the ext DABT has been properly injected, + * otherwise risking indefinitely re-running the faulting instruct= ion + * Covering a very narrow case for kernels 5.5..5.5.4 + * when injected abort was misconfigured to be + * an IMPLEMENTATION DEFINED exception (for 32-bit EL1) + */ + if (!arm_feature(env, ARM_FEATURE_AARCH64) && + unlikely(!kvm_arm_verify_ext_dabt_pending(cs))) { + + error_report("Data abort exception with no valid ISS generated= by " + "guest memory access. KVM unable to emulate faulting " + "instruction. Failed to inject an external data abort " + "into the guest."); + abort(); + } + /* Clear the status */ + env->ext_dabt_raised =3D 0; + } +} + +MemTxAttrs kvm_arch_post_run(CPUState *cs, struct kvm_run *run) +{ + ARMCPU *cpu; + uint32_t switched_level; + + if (kvm_irqchip_in_kernel()) { + /* + * We only need to sync timer states with user-space interrupt + * controllers, so return early and save cycles if we don't. + */ + return MEMTXATTRS_UNSPECIFIED; + } + + cpu =3D ARM_CPU(cs); + + /* Synchronize our shadowed in-kernel device irq lines with the kvm on= es */ + if (run->s.regs.device_irq_level !=3D cpu->device_irq_level) { + switched_level =3D cpu->device_irq_level ^ run->s.regs.device_irq_= level; + + qemu_mutex_lock_iothread(); + + if (switched_level & KVM_ARM_DEV_EL1_VTIMER) { + qemu_set_irq(cpu->gt_timer_outputs[GTIMER_VIRT], + !!(run->s.regs.device_irq_level & + KVM_ARM_DEV_EL1_VTIMER)); + switched_level &=3D ~KVM_ARM_DEV_EL1_VTIMER; + } + + if (switched_level & KVM_ARM_DEV_EL1_PTIMER) { + qemu_set_irq(cpu->gt_timer_outputs[GTIMER_PHYS], + !!(run->s.regs.device_irq_level & + KVM_ARM_DEV_EL1_PTIMER)); + switched_level &=3D ~KVM_ARM_DEV_EL1_PTIMER; + } + + if (switched_level & KVM_ARM_DEV_PMU) { + qemu_set_irq(cpu->pmu_interrupt, + !!(run->s.regs.device_irq_level & KVM_ARM_DEV_PMU= )); + switched_level &=3D ~KVM_ARM_DEV_PMU; + } + + if (switched_level) { + qemu_log_mask(LOG_UNIMP, "%s: unhandled in-kernel device IRQ %= x\n", + __func__, switched_level); + } + + /* We also mark unknown levels as processed to not waste cycles */ + cpu->device_irq_level =3D run->s.regs.device_irq_level; + qemu_mutex_unlock_iothread(); + } + + return MEMTXATTRS_UNSPECIFIED; +} diff --git a/target/arm/kvm64.c b/target/arm/kvm64.c deleted file mode 100644 index 2cdd7517b8..0000000000 --- a/target/arm/kvm64.c +++ /dev/null @@ -1,1632 +0,0 @@ -/* - * ARM implementation of KVM hooks, 64 bit specific code - * - * Copyright Mian-M. Hamayun 2013, Virtual Open Systems - * Copyright Alex Benn=C3=A9e 2014, Linaro - * - * This work is licensed under the terms of the GNU GPL, version 2 or late= r. - * See the COPYING file in the top-level directory. - * - */ - -#include "qemu/osdep.h" -#include -#include - -#include -#include - -#include "qapi/error.h" -#include "cpu.h" -#include "qemu/timer.h" -#include "qemu/error-report.h" -#include "qemu/host-utils.h" -#include "qemu/main-loop.h" -#include "exec/gdbstub.h" -#include "sysemu/runstate.h" -#include "sysemu/kvm.h" -#include "sysemu/kvm_int.h" -#include "kvm_arm.h" -#include "internals.h" -#include "hw/acpi/acpi.h" -#include "hw/acpi/ghes.h" -#include "hw/arm/virt.h" - -static bool have_guest_debug; - -/* - * Although the ARM implementation of hardware assisted debugging - * allows for different breakpoints per-core, the current GDB - * interface treats them as a global pool of registers (which seems to - * be the case for x86, ppc and s390). As a result we store one copy - * of registers which is used for all active cores. - * - * Write access is serialised by virtue of the GDB protocol which - * updates things. Read access (i.e. when the values are copied to the - * vCPU) is also gated by GDB's run control. - * - * This is not unreasonable as most of the time debugging kernels you - * never know which core will eventually execute your function. - */ - -typedef struct { - uint64_t bcr; - uint64_t bvr; -} HWBreakpoint; - -/* The watchpoint registers can cover more area than the requested - * watchpoint so we need to store the additional information - * somewhere. We also need to supply a CPUWatchpoint to the GDB stub - * when the watchpoint is hit. - */ -typedef struct { - uint64_t wcr; - uint64_t wvr; - CPUWatchpoint details; -} HWWatchpoint; - -/* Maximum and current break/watch point counts */ -int max_hw_bps, max_hw_wps; -GArray *hw_breakpoints, *hw_watchpoints; - -#define cur_hw_wps (hw_watchpoints->len) -#define cur_hw_bps (hw_breakpoints->len) -#define get_hw_bp(i) (&g_array_index(hw_breakpoints, HWBreakpoint, i)) -#define get_hw_wp(i) (&g_array_index(hw_watchpoints, HWWatchpoint, i)) - -/** - * kvm_arm_init_debug() - check for guest debug capabilities - * @cs: CPUState - * - * kvm_check_extension returns the number of debug registers we have - * or 0 if we have none. - * - */ -static void kvm_arm_init_debug(CPUState *cs) -{ - have_guest_debug =3D kvm_check_extension(cs->kvm_state, - KVM_CAP_SET_GUEST_DEBUG); - - max_hw_wps =3D kvm_check_extension(cs->kvm_state, KVM_CAP_GUEST_DEBUG_= HW_WPS); - hw_watchpoints =3D g_array_sized_new(true, true, - sizeof(HWWatchpoint), max_hw_wps); - - max_hw_bps =3D kvm_check_extension(cs->kvm_state, KVM_CAP_GUEST_DEBUG_= HW_BPS); - hw_breakpoints =3D g_array_sized_new(true, true, - sizeof(HWBreakpoint), max_hw_bps); - return; -} - -/** - * insert_hw_breakpoint() - * @addr: address of breakpoint - * - * See ARM ARM D2.9.1 for details but here we are only going to create - * simple un-linked breakpoints (i.e. we don't chain breakpoints - * together to match address and context or vmid). The hardware is - * capable of fancier matching but that will require exposing that - * fanciness to GDB's interface - * - * DBGBCR_EL1, Debug Breakpoint Control Registers - * - * 31 24 23 20 19 16 15 14 13 12 9 8 5 4 3 2 1 0 - * +------+------+-------+-----+----+------+-----+------+-----+---+ - * | RES0 | BT | LBN | SSC | HMC| RES0 | BAS | RES0 | PMC | E | - * +------+------+-------+-----+----+------+-----+------+-----+---+ - * - * BT: Breakpoint type (0 =3D unlinked address match) - * LBN: Linked BP number (0 =3D unused) - * SSC/HMC/PMC: Security, Higher and Priv access control (Table D-12) - * BAS: Byte Address Select (RES1 for AArch64) - * E: Enable bit - * - * DBGBVR_EL1, Debug Breakpoint Value Registers - * - * 63 53 52 49 48 2 1 0 - * +------+-----------+----------+-----+ - * | RESS | VA[52:49] | VA[48:2] | 0 0 | - * +------+-----------+----------+-----+ - * - * Depending on the addressing mode bits the top bits of the register - * are a sign extension of the highest applicable VA bit. Some - * versions of GDB don't do it correctly so we ensure they are correct - * here so future PC comparisons will work properly. - */ - -static int insert_hw_breakpoint(target_ulong addr) -{ - HWBreakpoint brk =3D { - .bcr =3D 0x1, /* BCR E=3D1, enable */ - .bvr =3D sextract64(addr, 0, 53) - }; - - if (cur_hw_bps >=3D max_hw_bps) { - return -ENOBUFS; - } - - brk.bcr =3D deposit32(brk.bcr, 1, 2, 0x3); /* PMC =3D 11 */ - brk.bcr =3D deposit32(brk.bcr, 5, 4, 0xf); /* BAS =3D RES1 */ - - g_array_append_val(hw_breakpoints, brk); - - return 0; -} - -/** - * delete_hw_breakpoint() - * @pc: address of breakpoint - * - * Delete a breakpoint and shuffle any above down - */ - -static int delete_hw_breakpoint(target_ulong pc) -{ - int i; - for (i =3D 0; i < hw_breakpoints->len; i++) { - HWBreakpoint *brk =3D get_hw_bp(i); - if (brk->bvr =3D=3D pc) { - g_array_remove_index(hw_breakpoints, i); - return 0; - } - } - return -ENOENT; -} - -/** - * insert_hw_watchpoint() - * @addr: address of watch point - * @len: size of area - * @type: type of watch point - * - * See ARM ARM D2.10. As with the breakpoints we can do some advanced - * stuff if we want to. The watch points can be linked with the break - * points above to make them context aware. However for simplicity - * currently we only deal with simple read/write watch points. - * - * D7.3.11 DBGWCR_EL1, Debug Watchpoint Control Registers - * - * 31 29 28 24 23 21 20 19 16 15 14 13 12 5 4 3 2 1 0 - * +------+-------+------+----+-----+-----+-----+-----+-----+-----+---+ - * | RES0 | MASK | RES0 | WT | LBN | SSC | HMC | BAS | LSC | PAC | E | - * +------+-------+------+----+-----+-----+-----+-----+-----+-----+---+ - * - * MASK: num bits addr mask (0=3Dnone,01/10=3Dres,11=3D3 bits (8 bytes)) - * WT: 0 - unlinked, 1 - linked (not currently used) - * LBN: Linked BP number (not currently used) - * SSC/HMC/PAC: Security, Higher and Priv access control (Table D2-11) - * BAS: Byte Address Select - * LSC: Load/Store control (01: load, 10: store, 11: both) - * E: Enable - * - * The bottom 2 bits of the value register are masked. Therefore to - * break on any sizes smaller than an unaligned word you need to set - * MASK=3D0, BAS=3Dbit per byte in question. For larger regions (^2) you - * need to ensure you mask the address as required and set BAS=3D0xff - */ - -static int insert_hw_watchpoint(target_ulong addr, - target_ulong len, int type) -{ - HWWatchpoint wp =3D { - .wcr =3D R_DBGWCR_E_MASK, /* E=3D1, enable */ - .wvr =3D addr & (~0x7ULL), - .details =3D { .vaddr =3D addr, .len =3D len } - }; - - if (cur_hw_wps >=3D max_hw_wps) { - return -ENOBUFS; - } - - /* - * HMC=3D0 SSC=3D0 PAC=3D3 will hit EL0 or EL1, any security state, - * valid whether EL3 is implemented or not - */ - wp.wcr =3D FIELD_DP64(wp.wcr, DBGWCR, PAC, 3); - - switch (type) { - case GDB_WATCHPOINT_READ: - wp.wcr =3D FIELD_DP64(wp.wcr, DBGWCR, LSC, 1); - wp.details.flags =3D BP_MEM_READ; - break; - case GDB_WATCHPOINT_WRITE: - wp.wcr =3D FIELD_DP64(wp.wcr, DBGWCR, LSC, 2); - wp.details.flags =3D BP_MEM_WRITE; - break; - case GDB_WATCHPOINT_ACCESS: - wp.wcr =3D FIELD_DP64(wp.wcr, DBGWCR, LSC, 3); - wp.details.flags =3D BP_MEM_ACCESS; - break; - default: - g_assert_not_reached(); - break; - } - if (len <=3D 8) { - /* we align the address and set the bits in BAS */ - int off =3D addr & 0x7; - int bas =3D (1 << len) - 1; - - wp.wcr =3D deposit32(wp.wcr, 5 + off, 8 - off, bas); - } else { - /* For ranges above 8 bytes we need to be a power of 2 */ - if (is_power_of_2(len)) { - int bits =3D ctz64(len); - - wp.wvr &=3D ~((1 << bits) - 1); - wp.wcr =3D FIELD_DP64(wp.wcr, DBGWCR, MASK, bits); - wp.wcr =3D FIELD_DP64(wp.wcr, DBGWCR, BAS, 0xff); - } else { - return -ENOBUFS; - } - } - - g_array_append_val(hw_watchpoints, wp); - return 0; -} - - -static bool check_watchpoint_in_range(int i, target_ulong addr) -{ - HWWatchpoint *wp =3D get_hw_wp(i); - uint64_t addr_top, addr_bottom =3D wp->wvr; - int bas =3D extract32(wp->wcr, 5, 8); - int mask =3D extract32(wp->wcr, 24, 4); - - if (mask) { - addr_top =3D addr_bottom + (1 << mask); - } else { - /* BAS must be contiguous but can offset against the base - * address in DBGWVR */ - addr_bottom =3D addr_bottom + ctz32(bas); - addr_top =3D addr_bottom + clo32(bas); - } - - if (addr >=3D addr_bottom && addr <=3D addr_top) { - return true; - } - - return false; -} - -/** - * delete_hw_watchpoint() - * @addr: address of breakpoint - * - * Delete a breakpoint and shuffle any above down - */ - -static int delete_hw_watchpoint(target_ulong addr, - target_ulong len, int type) -{ - int i; - for (i =3D 0; i < cur_hw_wps; i++) { - if (check_watchpoint_in_range(i, addr)) { - g_array_remove_index(hw_watchpoints, i); - return 0; - } - } - return -ENOENT; -} - - -int kvm_arch_insert_hw_breakpoint(target_ulong addr, - target_ulong len, int type) -{ - switch (type) { - case GDB_BREAKPOINT_HW: - return insert_hw_breakpoint(addr); - break; - case GDB_WATCHPOINT_READ: - case GDB_WATCHPOINT_WRITE: - case GDB_WATCHPOINT_ACCESS: - return insert_hw_watchpoint(addr, len, type); - default: - return -ENOSYS; - } -} - -int kvm_arch_remove_hw_breakpoint(target_ulong addr, - target_ulong len, int type) -{ - switch (type) { - case GDB_BREAKPOINT_HW: - return delete_hw_breakpoint(addr); - case GDB_WATCHPOINT_READ: - case GDB_WATCHPOINT_WRITE: - case GDB_WATCHPOINT_ACCESS: - return delete_hw_watchpoint(addr, len, type); - default: - return -ENOSYS; - } -} - - -void kvm_arch_remove_all_hw_breakpoints(void) -{ - if (cur_hw_wps > 0) { - g_array_remove_range(hw_watchpoints, 0, cur_hw_wps); - } - if (cur_hw_bps > 0) { - g_array_remove_range(hw_breakpoints, 0, cur_hw_bps); - } -} - -void kvm_arm_copy_hw_debug_data(struct kvm_guest_debug_arch *ptr) -{ - int i; - memset(ptr, 0, sizeof(struct kvm_guest_debug_arch)); - - for (i =3D 0; i < max_hw_wps; i++) { - HWWatchpoint *wp =3D get_hw_wp(i); - ptr->dbg_wcr[i] =3D wp->wcr; - ptr->dbg_wvr[i] =3D wp->wvr; - } - for (i =3D 0; i < max_hw_bps; i++) { - HWBreakpoint *bp =3D get_hw_bp(i); - ptr->dbg_bcr[i] =3D bp->bcr; - ptr->dbg_bvr[i] =3D bp->bvr; - } -} - -bool kvm_arm_hw_debug_active(CPUState *cs) -{ - return ((cur_hw_wps > 0) || (cur_hw_bps > 0)); -} - -static bool find_hw_breakpoint(CPUState *cpu, target_ulong pc) -{ - int i; - - for (i =3D 0; i < cur_hw_bps; i++) { - HWBreakpoint *bp =3D get_hw_bp(i); - if (bp->bvr =3D=3D pc) { - return true; - } - } - return false; -} - -static CPUWatchpoint *find_hw_watchpoint(CPUState *cpu, target_ulong addr) -{ - int i; - - for (i =3D 0; i < cur_hw_wps; i++) { - if (check_watchpoint_in_range(i, addr)) { - return &get_hw_wp(i)->details; - } - } - return NULL; -} - -static bool kvm_arm_set_device_attr(CPUState *cs, struct kvm_device_attr *= attr, - const char *name) -{ - int err; - - err =3D kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, attr); - if (err !=3D 0) { - error_report("%s: KVM_HAS_DEVICE_ATTR: %s", name, strerror(-err)); - return false; - } - - err =3D kvm_vcpu_ioctl(cs, KVM_SET_DEVICE_ATTR, attr); - if (err !=3D 0) { - error_report("%s: KVM_SET_DEVICE_ATTR: %s", name, strerror(-err)); - return false; - } - - return true; -} - -void kvm_arm_pmu_init(CPUState *cs) -{ - struct kvm_device_attr attr =3D { - .group =3D KVM_ARM_VCPU_PMU_V3_CTRL, - .attr =3D KVM_ARM_VCPU_PMU_V3_INIT, - }; - - if (!ARM_CPU(cs)->has_pmu) { - return; - } - if (!kvm_arm_set_device_attr(cs, &attr, "PMU")) { - error_report("failed to init PMU"); - abort(); - } -} - -void kvm_arm_pmu_set_irq(CPUState *cs, int irq) -{ - struct kvm_device_attr attr =3D { - .group =3D KVM_ARM_VCPU_PMU_V3_CTRL, - .addr =3D (intptr_t)&irq, - .attr =3D KVM_ARM_VCPU_PMU_V3_IRQ, - }; - - if (!ARM_CPU(cs)->has_pmu) { - return; - } - if (!kvm_arm_set_device_attr(cs, &attr, "PMU")) { - error_report("failed to set irq for PMU"); - abort(); - } -} - -void kvm_arm_pvtime_init(CPUState *cs, uint64_t ipa) -{ - struct kvm_device_attr attr =3D { - .group =3D KVM_ARM_VCPU_PVTIME_CTRL, - .attr =3D KVM_ARM_VCPU_PVTIME_IPA, - .addr =3D (uint64_t)&ipa, - }; - - if (ARM_CPU(cs)->kvm_steal_time =3D=3D ON_OFF_AUTO_OFF) { - return; - } - if (!kvm_arm_set_device_attr(cs, &attr, "PVTIME IPA")) { - error_report("failed to init PVTIME IPA"); - abort(); - } -} - -static int read_sys_reg32(int fd, uint32_t *pret, uint64_t id) -{ - uint64_t ret; - struct kvm_one_reg idreg =3D { .id =3D id, .addr =3D (uintptr_t)&ret }; - int err; - - assert((id & KVM_REG_SIZE_MASK) =3D=3D KVM_REG_SIZE_U64); - err =3D ioctl(fd, KVM_GET_ONE_REG, &idreg); - if (err < 0) { - return -1; - } - *pret =3D ret; - return 0; -} - -static int read_sys_reg64(int fd, uint64_t *pret, uint64_t id) -{ - struct kvm_one_reg idreg =3D { .id =3D id, .addr =3D (uintptr_t)pret }; - - assert((id & KVM_REG_SIZE_MASK) =3D=3D KVM_REG_SIZE_U64); - return ioctl(fd, KVM_GET_ONE_REG, &idreg); -} - -static bool kvm_arm_pauth_supported(void) -{ - return (kvm_check_extension(kvm_state, KVM_CAP_ARM_PTRAUTH_ADDRESS) && - kvm_check_extension(kvm_state, KVM_CAP_ARM_PTRAUTH_GENERIC)); -} - -bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) -{ - /* Identify the feature bits corresponding to the host CPU, and - * fill out the ARMHostCPUClass fields accordingly. To do this - * we have to create a scratch VM, create a single CPU inside it, - * and then query that CPU for the relevant ID registers. - */ - int fdarray[3]; - bool sve_supported; - bool pmu_supported =3D false; - uint64_t features =3D 0; - int err; - - /* Old kernels may not know about the PREFERRED_TARGET ioctl: however - * we know these will only support creating one kind of guest CPU, - * which is its preferred CPU type. Fortunately these old kernels - * support only a very limited number of CPUs. - */ - static const uint32_t cpus_to_try[] =3D { - KVM_ARM_TARGET_AEM_V8, - KVM_ARM_TARGET_FOUNDATION_V8, - KVM_ARM_TARGET_CORTEX_A57, - QEMU_KVM_ARM_TARGET_NONE - }; - /* - * target =3D -1 informs kvm_arm_create_scratch_host_vcpu() - * to use the preferred target - */ - struct kvm_vcpu_init init =3D { .target =3D -1, }; - - /* - * Ask for SVE if supported, so that we can query ID_AA64ZFR0, - * which is otherwise RAZ. - */ - sve_supported =3D kvm_arm_sve_supported(); - if (sve_supported) { - init.features[0] |=3D 1 << KVM_ARM_VCPU_SVE; - } - - /* - * Ask for Pointer Authentication if supported, so that we get - * the unsanitized field values for AA64ISAR1_EL1. - */ - if (kvm_arm_pauth_supported()) { - init.features[0] |=3D (1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS | - 1 << KVM_ARM_VCPU_PTRAUTH_GENERIC); - } - - if (kvm_arm_pmu_supported()) { - init.features[0] |=3D 1 << KVM_ARM_VCPU_PMU_V3; - pmu_supported =3D true; - } - - if (!kvm_arm_create_scratch_host_vcpu(cpus_to_try, fdarray, &init)) { - return false; - } - - ahcf->target =3D init.target; - ahcf->dtb_compatible =3D "arm,arm-v8"; - - err =3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64pfr0, - ARM64_SYS_REG(3, 0, 0, 4, 0)); - if (unlikely(err < 0)) { - /* - * Before v4.15, the kernel only exposed a limited number of system - * registers, not including any of the interesting AArch64 ID regs. - * For the most part we could leave these fields as zero with mini= mal - * effect, since this does not affect the values seen by the guest. - * - * However, it could cause problems down the line for QEMU, - * so provide a minimal v8.0 default. - * - * ??? Could read MIDR and use knowledge from cpu64.c. - * ??? Could map a page of memory into our temp guest and - * run the tiniest of hand-crafted kernels to extract - * the values seen by the guest. - * ??? Either of these sounds like too much effort just - * to work around running a modern host kernel. - */ - ahcf->isar.id_aa64pfr0 =3D 0x00000011; /* EL1&0, AArch64 only */ - err =3D 0; - } else { - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64pfr1, - ARM64_SYS_REG(3, 0, 0, 4, 1)); - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64smfr0, - ARM64_SYS_REG(3, 0, 0, 4, 5)); - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64dfr0, - ARM64_SYS_REG(3, 0, 0, 5, 0)); - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64dfr1, - ARM64_SYS_REG(3, 0, 0, 5, 1)); - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64isar0, - ARM64_SYS_REG(3, 0, 0, 6, 0)); - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64isar1, - ARM64_SYS_REG(3, 0, 0, 6, 1)); - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr0, - ARM64_SYS_REG(3, 0, 0, 7, 0)); - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr1, - ARM64_SYS_REG(3, 0, 0, 7, 1)); - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr2, - ARM64_SYS_REG(3, 0, 0, 7, 2)); - - /* - * Note that if AArch32 support is not present in the host, - * the AArch32 sysregs are present to be read, but will - * return UNKNOWN values. This is neither better nor worse - * than skipping the reads and leaving 0, as we must avoid - * considering the values in every case. - */ - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr0, - ARM64_SYS_REG(3, 0, 0, 1, 0)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr1, - ARM64_SYS_REG(3, 0, 0, 1, 1)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_dfr0, - ARM64_SYS_REG(3, 0, 0, 1, 2)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr0, - ARM64_SYS_REG(3, 0, 0, 1, 4)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr1, - ARM64_SYS_REG(3, 0, 0, 1, 5)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr2, - ARM64_SYS_REG(3, 0, 0, 1, 6)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr3, - ARM64_SYS_REG(3, 0, 0, 1, 7)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_isar0, - ARM64_SYS_REG(3, 0, 0, 2, 0)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_isar1, - ARM64_SYS_REG(3, 0, 0, 2, 1)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_isar2, - ARM64_SYS_REG(3, 0, 0, 2, 2)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_isar3, - ARM64_SYS_REG(3, 0, 0, 2, 3)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_isar4, - ARM64_SYS_REG(3, 0, 0, 2, 4)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_isar5, - ARM64_SYS_REG(3, 0, 0, 2, 5)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr4, - ARM64_SYS_REG(3, 0, 0, 2, 6)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_isar6, - ARM64_SYS_REG(3, 0, 0, 2, 7)); - - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.mvfr0, - ARM64_SYS_REG(3, 0, 0, 3, 0)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.mvfr1, - ARM64_SYS_REG(3, 0, 0, 3, 1)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.mvfr2, - ARM64_SYS_REG(3, 0, 0, 3, 2)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr2, - ARM64_SYS_REG(3, 0, 0, 3, 4)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_dfr1, - ARM64_SYS_REG(3, 0, 0, 3, 5)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr5, - ARM64_SYS_REG(3, 0, 0, 3, 6)); - - /* - * DBGDIDR is a bit complicated because the kernel doesn't - * provide an accessor for it in 64-bit mode, which is what this - * scratch VM is in, and there's no architected "64-bit sysreg - * which reads the same as the 32-bit register" the way there is - * for other ID registers. Instead we synthesize a value from the - * AArch64 ID_AA64DFR0, the same way the kernel code in - * arch/arm64/kvm/sys_regs.c:trap_dbgidr() does. - * We only do this if the CPU supports AArch32 at EL1. - */ - if (FIELD_EX32(ahcf->isar.id_aa64pfr0, ID_AA64PFR0, EL1) >=3D 2) { - int wrps =3D FIELD_EX64(ahcf->isar.id_aa64dfr0, ID_AA64DFR0, W= RPS); - int brps =3D FIELD_EX64(ahcf->isar.id_aa64dfr0, ID_AA64DFR0, B= RPS); - int ctx_cmps =3D - FIELD_EX64(ahcf->isar.id_aa64dfr0, ID_AA64DFR0, CTX_CMPS); - int version =3D 6; /* ARMv8 debug architecture */ - bool has_el3 =3D - !!FIELD_EX32(ahcf->isar.id_aa64pfr0, ID_AA64PFR0, EL3); - uint32_t dbgdidr =3D 0; - - dbgdidr =3D FIELD_DP32(dbgdidr, DBGDIDR, WRPS, wrps); - dbgdidr =3D FIELD_DP32(dbgdidr, DBGDIDR, BRPS, brps); - dbgdidr =3D FIELD_DP32(dbgdidr, DBGDIDR, CTX_CMPS, ctx_cmps); - dbgdidr =3D FIELD_DP32(dbgdidr, DBGDIDR, VERSION, version); - dbgdidr =3D FIELD_DP32(dbgdidr, DBGDIDR, NSUHD_IMP, has_el3); - dbgdidr =3D FIELD_DP32(dbgdidr, DBGDIDR, SE_IMP, has_el3); - dbgdidr |=3D (1 << 15); /* RES1 bit */ - ahcf->isar.dbgdidr =3D dbgdidr; - } - - if (pmu_supported) { - /* PMCR_EL0 is only accessible if the vCPU has feature PMU_V3 = */ - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.reset_pmcr_el0, - ARM64_SYS_REG(3, 3, 9, 12, 0)); - } - - if (sve_supported) { - /* - * There is a range of kernels between kernel commit 73433762f= cae - * and f81cb2c3ad41 which have a bug where the kernel doesn't - * expose SYS_ID_AA64ZFR0_EL1 via the ONE_REG API unless the V= M has - * enabled SVE support, which resulted in an error rather than= RAZ. - * So only read the register if we set KVM_ARM_VCPU_SVE above. - */ - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64zfr0, - ARM64_SYS_REG(3, 0, 0, 4, 4)); - } - } - - kvm_arm_destroy_scratch_host_vcpu(fdarray); - - if (err < 0) { - return false; - } - - /* - * We can assume any KVM supporting CPU is at least a v8 - * with VFPv4+Neon; this in turn implies most of the other - * feature bits. - */ - features |=3D 1ULL << ARM_FEATURE_V8; - features |=3D 1ULL << ARM_FEATURE_NEON; - features |=3D 1ULL << ARM_FEATURE_AARCH64; - features |=3D 1ULL << ARM_FEATURE_PMU; - features |=3D 1ULL << ARM_FEATURE_GENERIC_TIMER; - - ahcf->features =3D features; - - return true; -} - -void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp) -{ - bool has_steal_time =3D kvm_arm_steal_time_supported(); - - if (cpu->kvm_steal_time =3D=3D ON_OFF_AUTO_AUTO) { - if (!has_steal_time || !arm_feature(&cpu->env, ARM_FEATURE_AARCH64= )) { - cpu->kvm_steal_time =3D ON_OFF_AUTO_OFF; - } else { - cpu->kvm_steal_time =3D ON_OFF_AUTO_ON; - } - } else if (cpu->kvm_steal_time =3D=3D ON_OFF_AUTO_ON) { - if (!has_steal_time) { - error_setg(errp, "'kvm-steal-time' cannot be enabled " - "on this host"); - return; - } else if (!arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { - /* - * DEN0057A chapter 2 says "This specification only covers - * systems in which the Execution state of the hypervisor - * as well as EL1 of virtual machines is AArch64.". And, - * to ensure that, the smc/hvc calls are only specified as - * smc64/hvc64. - */ - error_setg(errp, "'kvm-steal-time' cannot be enabled " - "for AArch32 guests"); - return; - } - } -} - -bool kvm_arm_aarch32_supported(void) -{ - return kvm_check_extension(kvm_state, KVM_CAP_ARM_EL1_32BIT); -} - -bool kvm_arm_sve_supported(void) -{ - return kvm_check_extension(kvm_state, KVM_CAP_ARM_SVE); -} - -bool kvm_arm_steal_time_supported(void) -{ - return kvm_check_extension(kvm_state, KVM_CAP_STEAL_TIME); -} - -QEMU_BUILD_BUG_ON(KVM_ARM64_SVE_VQ_MIN !=3D 1); - -uint32_t kvm_arm_sve_get_vls(CPUState *cs) -{ - /* Only call this function if kvm_arm_sve_supported() returns true. */ - static uint64_t vls[KVM_ARM64_SVE_VLS_WORDS]; - static bool probed; - uint32_t vq =3D 0; - int i; - - /* - * KVM ensures all host CPUs support the same set of vector lengths. - * So we only need to create the scratch VCPUs once and then cache - * the results. - */ - if (!probed) { - struct kvm_vcpu_init init =3D { - .target =3D -1, - .features[0] =3D (1 << KVM_ARM_VCPU_SVE), - }; - struct kvm_one_reg reg =3D { - .id =3D KVM_REG_ARM64_SVE_VLS, - .addr =3D (uint64_t)&vls[0], - }; - int fdarray[3], ret; - - probed =3D true; - - if (!kvm_arm_create_scratch_host_vcpu(NULL, fdarray, &init)) { - error_report("failed to create scratch VCPU with SVE enabled"); - abort(); - } - ret =3D ioctl(fdarray[2], KVM_GET_ONE_REG, ®); - kvm_arm_destroy_scratch_host_vcpu(fdarray); - if (ret) { - error_report("failed to get KVM_REG_ARM64_SVE_VLS: %s", - strerror(errno)); - abort(); - } - - for (i =3D KVM_ARM64_SVE_VLS_WORDS - 1; i >=3D 0; --i) { - if (vls[i]) { - vq =3D 64 - clz64(vls[i]) + i * 64; - break; - } - } - if (vq > ARM_MAX_VQ) { - warn_report("KVM supports vector lengths larger than " - "QEMU can enable"); - vls[0] &=3D MAKE_64BIT_MASK(0, ARM_MAX_VQ); - } - } - - return vls[0]; -} - -static int kvm_arm_sve_set_vls(CPUState *cs) -{ - ARMCPU *cpu =3D ARM_CPU(cs); - uint64_t vls[KVM_ARM64_SVE_VLS_WORDS] =3D { cpu->sve_vq.map }; - struct kvm_one_reg reg =3D { - .id =3D KVM_REG_ARM64_SVE_VLS, - .addr =3D (uint64_t)&vls[0], - }; - - assert(cpu->sve_max_vq <=3D KVM_ARM64_SVE_VQ_MAX); - - return kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); -} - -#define ARM_CPU_ID_MPIDR 3, 0, 0, 0, 5 - -int kvm_arch_init_vcpu(CPUState *cs) -{ - int ret; - uint64_t mpidr; - ARMCPU *cpu =3D ARM_CPU(cs); - CPUARMState *env =3D &cpu->env; - uint64_t psciver; - - if (cpu->kvm_target =3D=3D QEMU_KVM_ARM_TARGET_NONE || - !object_dynamic_cast(OBJECT(cpu), TYPE_AARCH64_CPU)) { - error_report("KVM is not supported for this guest CPU type"); - return -EINVAL; - } - - qemu_add_vm_change_state_handler(kvm_arm_vm_state_change, cs); - - /* Determine init features for this CPU */ - memset(cpu->kvm_init_features, 0, sizeof(cpu->kvm_init_features)); - if (cs->start_powered_off) { - cpu->kvm_init_features[0] |=3D 1 << KVM_ARM_VCPU_POWER_OFF; - } - if (kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PSCI_0_2)) { - cpu->psci_version =3D QEMU_PSCI_VERSION_0_2; - cpu->kvm_init_features[0] |=3D 1 << KVM_ARM_VCPU_PSCI_0_2; - } - if (!arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { - cpu->kvm_init_features[0] |=3D 1 << KVM_ARM_VCPU_EL1_32BIT; - } - if (!kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PMU_V3)) { - cpu->has_pmu =3D false; - } - if (cpu->has_pmu) { - cpu->kvm_init_features[0] |=3D 1 << KVM_ARM_VCPU_PMU_V3; - } else { - env->features &=3D ~(1ULL << ARM_FEATURE_PMU); - } - if (cpu_isar_feature(aa64_sve, cpu)) { - assert(kvm_arm_sve_supported()); - cpu->kvm_init_features[0] |=3D 1 << KVM_ARM_VCPU_SVE; - } - if (cpu_isar_feature(aa64_pauth, cpu)) { - cpu->kvm_init_features[0] |=3D (1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS | - 1 << KVM_ARM_VCPU_PTRAUTH_GENERIC); - } - - /* Do KVM_ARM_VCPU_INIT ioctl */ - ret =3D kvm_arm_vcpu_init(cs); - if (ret) { - return ret; - } - - if (cpu_isar_feature(aa64_sve, cpu)) { - ret =3D kvm_arm_sve_set_vls(cs); - if (ret) { - return ret; - } - ret =3D kvm_arm_vcpu_finalize(cs, KVM_ARM_VCPU_SVE); - if (ret) { - return ret; - } - } - - /* - * KVM reports the exact PSCI version it is implementing via a - * special sysreg. If it is present, use its contents to determine - * what to report to the guest in the dtb (it is the PSCI version, - * in the same 15-bits major 16-bits minor format that PSCI_VERSION - * returns). - */ - if (!kvm_get_one_reg(cs, KVM_REG_ARM_PSCI_VERSION, &psciver)) { - cpu->psci_version =3D psciver; - } - - /* - * When KVM is in use, PSCI is emulated in-kernel and not by qemu. - * Currently KVM has its own idea about MPIDR assignment, so we - * override our defaults with what we get from KVM. - */ - ret =3D kvm_get_one_reg(cs, ARM64_SYS_REG(ARM_CPU_ID_MPIDR), - &cpu->mpidr_el1); - if (ret) { - return ret; - } - - kvm_arm_init_debug(cs); - - /* Check whether user space can specify guest syndrome value */ - kvm_arm_init_serror_injection(cs); - - return kvm_arm_init_cpreg_list(cpu); -} - -int kvm_arch_destroy_vcpu(CPUState *cs) -{ - return 0; -} - -bool kvm_arm_reg_syncs_via_cpreg_list(uint64_t regidx) -{ - /* Return true if the regidx is a register we should synchronize - * via the cpreg_tuples array (ie is not a core or sve reg that - * we sync by hand in kvm_arch_get/put_registers()) - */ - switch (regidx & KVM_REG_ARM_COPROC_MASK) { - case KVM_REG_ARM_CORE: - case KVM_REG_ARM64_SVE: - return false; - default: - return true; - } -} - -typedef struct CPRegStateLevel { - uint64_t regidx; - int level; -} CPRegStateLevel; - -/* All system registers not listed in the following table are assumed to be - * of the level KVM_PUT_RUNTIME_STATE. If a register should be written less - * often, you must add it to this table with a state of either - * KVM_PUT_RESET_STATE or KVM_PUT_FULL_STATE. - */ -static const CPRegStateLevel non_runtime_cpregs[] =3D { - { KVM_REG_ARM_TIMER_CNT, KVM_PUT_FULL_STATE }, -}; - -int kvm_arm_cpreg_level(uint64_t regidx) -{ - int i; - - for (i =3D 0; i < ARRAY_SIZE(non_runtime_cpregs); i++) { - const CPRegStateLevel *l =3D &non_runtime_cpregs[i]; - if (l->regidx =3D=3D regidx) { - return l->level; - } - } - - return KVM_PUT_RUNTIME_STATE; -} - -/* Callers must hold the iothread mutex lock */ -static void kvm_inject_arm_sea(CPUState *c) -{ - ARMCPU *cpu =3D ARM_CPU(c); - CPUARMState *env =3D &cpu->env; - uint32_t esr; - bool same_el; - - c->exception_index =3D EXCP_DATA_ABORT; - env->exception.target_el =3D 1; - - /* - * Set the DFSC to synchronous external abort and set FnV to not valid, - * this will tell guest the FAR_ELx is UNKNOWN for this abort. - */ - same_el =3D arm_current_el(env) =3D=3D env->exception.target_el; - esr =3D syn_data_abort_no_iss(same_el, 1, 0, 0, 0, 0, 0x10); - - env->exception.syndrome =3D esr; - - arm_cpu_do_interrupt(c); -} - -#define AARCH64_CORE_REG(x) (KVM_REG_ARM64 | KVM_REG_SIZE_U64 | \ - KVM_REG_ARM_CORE | KVM_REG_ARM_CORE_REG(x)) - -#define AARCH64_SIMD_CORE_REG(x) (KVM_REG_ARM64 | KVM_REG_SIZE_U128 | \ - KVM_REG_ARM_CORE | KVM_REG_ARM_CORE_REG(x)) - -#define AARCH64_SIMD_CTRL_REG(x) (KVM_REG_ARM64 | KVM_REG_SIZE_U32 | \ - KVM_REG_ARM_CORE | KVM_REG_ARM_CORE_REG(x)) - -static int kvm_arch_put_fpsimd(CPUState *cs) -{ - CPUARMState *env =3D &ARM_CPU(cs)->env; - struct kvm_one_reg reg; - int i, ret; - - for (i =3D 0; i < 32; i++) { - uint64_t *q =3D aa64_vfp_qreg(env, i); -#if HOST_BIG_ENDIAN - uint64_t fp_val[2] =3D { q[1], q[0] }; - reg.addr =3D (uintptr_t)fp_val; -#else - reg.addr =3D (uintptr_t)q; -#endif - reg.id =3D AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); - ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); - if (ret) { - return ret; - } - } - - return 0; -} - -/* - * KVM SVE registers come in slices where ZREGs have a slice size of 2048 = bits - * and PREGS and the FFR have a slice size of 256 bits. However we simply = hard - * code the slice index to zero for now as it's unlikely we'll need more t= han - * one slice for quite some time. - */ -static int kvm_arch_put_sve(CPUState *cs) -{ - ARMCPU *cpu =3D ARM_CPU(cs); - CPUARMState *env =3D &cpu->env; - uint64_t tmp[ARM_MAX_VQ * 2]; - uint64_t *r; - struct kvm_one_reg reg; - int n, ret; - - for (n =3D 0; n < KVM_ARM64_SVE_NUM_ZREGS; ++n) { - r =3D sve_bswap64(tmp, &env->vfp.zregs[n].d[0], cpu->sve_max_vq * = 2); - reg.addr =3D (uintptr_t)r; - reg.id =3D KVM_REG_ARM64_SVE_ZREG(n, 0); - ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); - if (ret) { - return ret; - } - } - - for (n =3D 0; n < KVM_ARM64_SVE_NUM_PREGS; ++n) { - r =3D sve_bswap64(tmp, r =3D &env->vfp.pregs[n].p[0], - DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); - reg.addr =3D (uintptr_t)r; - reg.id =3D KVM_REG_ARM64_SVE_PREG(n, 0); - ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); - if (ret) { - return ret; - } - } - - r =3D sve_bswap64(tmp, &env->vfp.pregs[FFR_PRED_NUM].p[0], - DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); - reg.addr =3D (uintptr_t)r; - reg.id =3D KVM_REG_ARM64_SVE_FFR(0); - ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); - if (ret) { - return ret; - } - - return 0; -} - -int kvm_arch_put_registers(CPUState *cs, int level) -{ - struct kvm_one_reg reg; - uint64_t val; - uint32_t fpr; - int i, ret; - unsigned int el; - - ARMCPU *cpu =3D ARM_CPU(cs); - CPUARMState *env =3D &cpu->env; - - /* If we are in AArch32 mode then we need to copy the AArch32 regs to = the - * AArch64 registers before pushing them out to 64-bit KVM. - */ - if (!is_a64(env)) { - aarch64_sync_32_to_64(env); - } - - for (i =3D 0; i < 31; i++) { - reg.id =3D AARCH64_CORE_REG(regs.regs[i]); - reg.addr =3D (uintptr_t) &env->xregs[i]; - ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); - if (ret) { - return ret; - } - } - - /* KVM puts SP_EL0 in regs.sp and SP_EL1 in regs.sp_el1. On the - * QEMU side we keep the current SP in xregs[31] as well. - */ - aarch64_save_sp(env, 1); - - reg.id =3D AARCH64_CORE_REG(regs.sp); - reg.addr =3D (uintptr_t) &env->sp_el[0]; - ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); - if (ret) { - return ret; - } - - reg.id =3D AARCH64_CORE_REG(sp_el1); - reg.addr =3D (uintptr_t) &env->sp_el[1]; - ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); - if (ret) { - return ret; - } - - /* Note that KVM thinks pstate is 64 bit but we use a uint32_t */ - if (is_a64(env)) { - val =3D pstate_read(env); - } else { - val =3D cpsr_read(env); - } - reg.id =3D AARCH64_CORE_REG(regs.pstate); - reg.addr =3D (uintptr_t) &val; - ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); - if (ret) { - return ret; - } - - reg.id =3D AARCH64_CORE_REG(regs.pc); - reg.addr =3D (uintptr_t) &env->pc; - ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); - if (ret) { - return ret; - } - - reg.id =3D AARCH64_CORE_REG(elr_el1); - reg.addr =3D (uintptr_t) &env->elr_el[1]; - ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); - if (ret) { - return ret; - } - - /* Saved Program State Registers - * - * Before we restore from the banked_spsr[] array we need to - * ensure that any modifications to env->spsr are correctly - * reflected in the banks. - */ - el =3D arm_current_el(env); - if (el > 0 && !is_a64(env)) { - i =3D bank_number(env->uncached_cpsr & CPSR_M); - env->banked_spsr[i] =3D env->spsr; - } - - /* KVM 0-4 map to QEMU banks 1-5 */ - for (i =3D 0; i < KVM_NR_SPSR; i++) { - reg.id =3D AARCH64_CORE_REG(spsr[i]); - reg.addr =3D (uintptr_t) &env->banked_spsr[i + 1]; - ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); - if (ret) { - return ret; - } - } - - if (cpu_isar_feature(aa64_sve, cpu)) { - ret =3D kvm_arch_put_sve(cs); - } else { - ret =3D kvm_arch_put_fpsimd(cs); - } - if (ret) { - return ret; - } - - reg.addr =3D (uintptr_t)(&fpr); - fpr =3D vfp_get_fpsr(env); - reg.id =3D AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); - ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); - if (ret) { - return ret; - } - - reg.addr =3D (uintptr_t)(&fpr); - fpr =3D vfp_get_fpcr(env); - reg.id =3D AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); - ret =3D kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); - if (ret) { - return ret; - } - - write_cpustate_to_list(cpu, true); - - if (!write_list_to_kvmstate(cpu, level)) { - return -EINVAL; - } - - /* - * Setting VCPU events should be triggered after syncing the registers - * to avoid overwriting potential changes made by KVM upon calling - * KVM_SET_VCPU_EVENTS ioctl - */ - ret =3D kvm_put_vcpu_events(cpu); - if (ret) { - return ret; - } - - kvm_arm_sync_mpstate_to_kvm(cpu); - - return ret; -} - -static int kvm_arch_get_fpsimd(CPUState *cs) -{ - CPUARMState *env =3D &ARM_CPU(cs)->env; - struct kvm_one_reg reg; - int i, ret; - - for (i =3D 0; i < 32; i++) { - uint64_t *q =3D aa64_vfp_qreg(env, i); - reg.id =3D AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); - reg.addr =3D (uintptr_t)q; - ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } else { -#if HOST_BIG_ENDIAN - uint64_t t; - t =3D q[0], q[0] =3D q[1], q[1] =3D t; -#endif - } - } - - return 0; -} - -/* - * KVM SVE registers come in slices where ZREGs have a slice size of 2048 = bits - * and PREGS and the FFR have a slice size of 256 bits. However we simply = hard - * code the slice index to zero for now as it's unlikely we'll need more t= han - * one slice for quite some time. - */ -static int kvm_arch_get_sve(CPUState *cs) -{ - ARMCPU *cpu =3D ARM_CPU(cs); - CPUARMState *env =3D &cpu->env; - struct kvm_one_reg reg; - uint64_t *r; - int n, ret; - - for (n =3D 0; n < KVM_ARM64_SVE_NUM_ZREGS; ++n) { - r =3D &env->vfp.zregs[n].d[0]; - reg.addr =3D (uintptr_t)r; - reg.id =3D KVM_REG_ARM64_SVE_ZREG(n, 0); - ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } - sve_bswap64(r, r, cpu->sve_max_vq * 2); - } - - for (n =3D 0; n < KVM_ARM64_SVE_NUM_PREGS; ++n) { - r =3D &env->vfp.pregs[n].p[0]; - reg.addr =3D (uintptr_t)r; - reg.id =3D KVM_REG_ARM64_SVE_PREG(n, 0); - ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } - sve_bswap64(r, r, DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); - } - - r =3D &env->vfp.pregs[FFR_PRED_NUM].p[0]; - reg.addr =3D (uintptr_t)r; - reg.id =3D KVM_REG_ARM64_SVE_FFR(0); - ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } - sve_bswap64(r, r, DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); - - return 0; -} - -int kvm_arch_get_registers(CPUState *cs) -{ - struct kvm_one_reg reg; - uint64_t val; - unsigned int el; - uint32_t fpr; - int i, ret; - - ARMCPU *cpu =3D ARM_CPU(cs); - CPUARMState *env =3D &cpu->env; - - for (i =3D 0; i < 31; i++) { - reg.id =3D AARCH64_CORE_REG(regs.regs[i]); - reg.addr =3D (uintptr_t) &env->xregs[i]; - ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } - } - - reg.id =3D AARCH64_CORE_REG(regs.sp); - reg.addr =3D (uintptr_t) &env->sp_el[0]; - ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } - - reg.id =3D AARCH64_CORE_REG(sp_el1); - reg.addr =3D (uintptr_t) &env->sp_el[1]; - ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } - - reg.id =3D AARCH64_CORE_REG(regs.pstate); - reg.addr =3D (uintptr_t) &val; - ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } - - env->aarch64 =3D ((val & PSTATE_nRW) =3D=3D 0); - if (is_a64(env)) { - pstate_write(env, val); - } else { - cpsr_write(env, val, 0xffffffff, CPSRWriteRaw); - } - - /* KVM puts SP_EL0 in regs.sp and SP_EL1 in regs.sp_el1. On the - * QEMU side we keep the current SP in xregs[31] as well. - */ - aarch64_restore_sp(env, 1); - - reg.id =3D AARCH64_CORE_REG(regs.pc); - reg.addr =3D (uintptr_t) &env->pc; - ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } - - /* If we are in AArch32 mode then we need to sync the AArch32 regs wit= h the - * incoming AArch64 regs received from 64-bit KVM. - * We must perform this after all of the registers have been acquired = from - * the kernel. - */ - if (!is_a64(env)) { - aarch64_sync_64_to_32(env); - } - - reg.id =3D AARCH64_CORE_REG(elr_el1); - reg.addr =3D (uintptr_t) &env->elr_el[1]; - ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } - - /* Fetch the SPSR registers - * - * KVM SPSRs 0-4 map to QEMU banks 1-5 - */ - for (i =3D 0; i < KVM_NR_SPSR; i++) { - reg.id =3D AARCH64_CORE_REG(spsr[i]); - reg.addr =3D (uintptr_t) &env->banked_spsr[i + 1]; - ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } - } - - el =3D arm_current_el(env); - if (el > 0 && !is_a64(env)) { - i =3D bank_number(env->uncached_cpsr & CPSR_M); - env->spsr =3D env->banked_spsr[i]; - } - - if (cpu_isar_feature(aa64_sve, cpu)) { - ret =3D kvm_arch_get_sve(cs); - } else { - ret =3D kvm_arch_get_fpsimd(cs); - } - if (ret) { - return ret; - } - - reg.addr =3D (uintptr_t)(&fpr); - reg.id =3D AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); - ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } - vfp_set_fpsr(env, fpr); - - reg.addr =3D (uintptr_t)(&fpr); - reg.id =3D AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); - ret =3D kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } - vfp_set_fpcr(env, fpr); - - ret =3D kvm_get_vcpu_events(cpu); - if (ret) { - return ret; - } - - if (!write_kvmstate_to_list(cpu)) { - return -EINVAL; - } - /* Note that it's OK to have registers which aren't in CPUState, - * so we can ignore a failure return here. - */ - write_list_to_cpustate(cpu); - - kvm_arm_sync_mpstate_to_qemu(cpu); - - /* TODO: other registers */ - return ret; -} - -void kvm_arch_on_sigbus_vcpu(CPUState *c, int code, void *addr) -{ - ram_addr_t ram_addr; - hwaddr paddr; - - assert(code =3D=3D BUS_MCEERR_AR || code =3D=3D BUS_MCEERR_AO); - - if (acpi_ghes_present() && addr) { - ram_addr =3D qemu_ram_addr_from_host(addr); - if (ram_addr !=3D RAM_ADDR_INVALID && - kvm_physical_memory_addr_from_host(c->kvm_state, addr, &paddr)= ) { - kvm_hwpoison_page_add(ram_addr); - /* - * If this is a BUS_MCEERR_AR, we know we have been called - * synchronously from the vCPU thread, so we can easily - * synchronize the state and inject an error. - * - * TODO: we currently don't tell the guest at all about - * BUS_MCEERR_AO. In that case we might either be being - * called synchronously from the vCPU thread, or a bit - * later from the main thread, so doing the injection of - * the error would be more complicated. - */ - if (code =3D=3D BUS_MCEERR_AR) { - kvm_cpu_synchronize_state(c); - if (!acpi_ghes_record_errors(ACPI_HEST_SRC_ID_SEA, paddr))= { - kvm_inject_arm_sea(c); - } else { - error_report("failed to record the error"); - abort(); - } - } - return; - } - if (code =3D=3D BUS_MCEERR_AO) { - error_report("Hardware memory error at addr %p for memory used= by " - "QEMU itself instead of guest system!", addr); - } - } - - if (code =3D=3D BUS_MCEERR_AR) { - error_report("Hardware memory error!"); - exit(1); - } -} - -/* C6.6.29 BRK instruction */ -static const uint32_t brk_insn =3D 0xd4200000; - -int kvm_arch_insert_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *= bp) -{ - if (have_guest_debug) { - if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4,= 0) || - cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk_insn, 4, 1)) { - return -EINVAL; - } - return 0; - } else { - error_report("guest debug not supported on this kernel"); - return -EINVAL; - } -} - -int kvm_arch_remove_sw_breakpoint(CPUState *cs, struct kvm_sw_breakpoint *= bp) -{ - static uint32_t brk; - - if (have_guest_debug) { - if (cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&brk, 4, 0) || - brk !=3D brk_insn || - cpu_memory_rw_debug(cs, bp->pc, (uint8_t *)&bp->saved_insn, 4,= 1)) { - return -EINVAL; - } - return 0; - } else { - error_report("guest debug not supported on this kernel"); - return -EINVAL; - } -} - -/* See v8 ARM ARM D7.2.27 ESR_ELx, Exception Syndrome Register - * - * To minimise translating between kernel and user-space the kernel - * ABI just provides user-space with the full exception syndrome - * register value to be decoded in QEMU. - */ - -bool kvm_arm_handle_debug(CPUState *cs, struct kvm_debug_exit_arch *debug_= exit) -{ - int hsr_ec =3D syn_get_ec(debug_exit->hsr); - ARMCPU *cpu =3D ARM_CPU(cs); - CPUARMState *env =3D &cpu->env; - - /* Ensure PC is synchronised */ - kvm_cpu_synchronize_state(cs); - - switch (hsr_ec) { - case EC_SOFTWARESTEP: - if (cs->singlestep_enabled) { - return true; - } else { - /* - * The kernel should have suppressed the guest's ability to - * single step at this point so something has gone wrong. - */ - error_report("%s: guest single-step while debugging unsupporte= d" - " (%"PRIx64", %"PRIx32")", - __func__, env->pc, debug_exit->hsr); - return false; - } - break; - case EC_AA64_BKPT: - if (kvm_find_sw_breakpoint(cs, env->pc)) { - return true; - } - break; - case EC_BREAKPOINT: - if (find_hw_breakpoint(cs, env->pc)) { - return true; - } - break; - case EC_WATCHPOINT: - { - CPUWatchpoint *wp =3D find_hw_watchpoint(cs, debug_exit->far); - if (wp) { - cs->watchpoint_hit =3D wp; - return true; - } - break; - } - default: - error_report("%s: unhandled debug exit (%"PRIx32", %"PRIx64")", - __func__, debug_exit->hsr, env->pc); - } - - /* If we are not handling the debug exception it must belong to - * the guest. Let's re-use the existing TCG interrupt code to set - * everything up properly. - */ - cs->exception_index =3D EXCP_BKPT; - env->exception.syndrome =3D debug_exit->hsr; - env->exception.vaddress =3D debug_exit->far; - env->exception.target_el =3D 1; - qemu_mutex_lock_iothread(); - arm_cpu_do_interrupt(cs); - qemu_mutex_unlock_iothread(); - - return false; -} - -#define ARM64_REG_ESR_EL1 ARM64_SYS_REG(3, 0, 5, 2, 0) -#define ARM64_REG_TCR_EL1 ARM64_SYS_REG(3, 0, 2, 0, 2) - -/* - * ESR_EL1 - * ISS encoding - * AARCH64: DFSC, bits [5:0] - * AARCH32: - * TTBCR.EAE =3D=3D 0 - * FS[4] - DFSR[10] - * FS[3:0] - DFSR[3:0] - * TTBCR.EAE =3D=3D 1 - * FS, bits [5:0] - */ -#define ESR_DFSC(aarch64, lpae, v) \ - ((aarch64 || (lpae)) ? ((v) & 0x3F) \ - : (((v) >> 6) | ((v) & 0x1F))) - -#define ESR_DFSC_EXTABT(aarch64, lpae) \ - ((aarch64) ? 0x10 : (lpae) ? 0x10 : 0x8) - -bool kvm_arm_verify_ext_dabt_pending(CPUState *cs) -{ - uint64_t dfsr_val; - - if (!kvm_get_one_reg(cs, ARM64_REG_ESR_EL1, &dfsr_val)) { - ARMCPU *cpu =3D ARM_CPU(cs); - CPUARMState *env =3D &cpu->env; - int aarch64_mode =3D arm_feature(env, ARM_FEATURE_AARCH64); - int lpae =3D 0; - - if (!aarch64_mode) { - uint64_t ttbcr; - - if (!kvm_get_one_reg(cs, ARM64_REG_TCR_EL1, &ttbcr)) { - lpae =3D arm_feature(env, ARM_FEATURE_LPAE) - && (ttbcr & TTBCR_EAE); - } - } - /* - * The verification here is based on the DFSC bits - * of the ESR_EL1 reg only - */ - return (ESR_DFSC(aarch64_mode, lpae, dfsr_val) =3D=3D - ESR_DFSC_EXTABT(aarch64_mode, lpae)); - } - return false; -} diff --git a/target/arm/meson.build b/target/arm/meson.build index 87e911b27f..f6c96ec184 100644 --- a/target/arm/meson.build +++ b/target/arm/meson.build @@ -40,7 +40,7 @@ arm_ss.add(files( )) arm_ss.add(zlib) =20 -arm_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c', 'kvm64.c'), if_fals= e: files('kvm-stub.c')) +arm_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c'), if_false: files('k= vm-stub.c')) =20 arm_ss.add(when: 'TARGET_AARCH64', if_true: files( 'cpu64.c', --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672769965; cv=none; d=zohomail.com; s=zohoarc; b=JcQoOp3pCjGbIdHDRrTxLJtaJzY8ibclVrqjfDf3umEWrYRG2N9BXAevFeV5okKzBVzHoZPV5tx4OD8+yMuNu+1fhZYSAiBnzOw6rmziPG1XOugHbmkM5+AeqM6oRmNwOgSQLocvfFCM9GYjxvbsUI4TI0DaKtG/oLoMMU6BRp0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672769965; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=DDbFWUAdD66ccbGgAfeLRZAs/Smk+GVAFx7IHK4amAk=; b=XsYTsWp1FcIV7cGhGrtOv5pjB8TsUWHEDFROpTMZJX55vKTttuH6gbOGmDNIln4TMMzS+8bcsZ+96pSvndokmeKo6xrDHfNiMxnycoId238pWE80TUJnS/E3mLqqfaYERrjvP4Q9peyR4DTlEHDNxPDQ24gAhfFTB4RGVZRG2wk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672769965196752.1851990525076; Tue, 3 Jan 2023 10:19:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClri-0000TB-Is; Tue, 03 Jan 2023 13:18:22 -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 1pClrH-0008Mi-Sn for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:55 -0500 Received: from mail-vs1-xe2e.google.com ([2607:f8b0:4864:20::e2e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClrF-0005HE-W9 for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:55 -0500 Received: by mail-vs1-xe2e.google.com with SMTP id o63so27788835vsc.10 for ; Tue, 03 Jan 2023 10:17:53 -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.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:52 -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=DDbFWUAdD66ccbGgAfeLRZAs/Smk+GVAFx7IHK4amAk=; b=QIfFCDIx/W7d74QjtjWe7bt8JniVrY7ODkBsJwGryfLm9jAp3K+oF9eh23UGyaskA5 9+ZUJr8zCkJcxqA7fljwMnWU5AGmSyD9V6KsEe7i2KkCCMQONDSBe0GL6FksPFtfdp4r zLxyyjES04YtJmMkKVRo1lKMbBdzALphAdct2ln5vbIS7YALojYeenm9/MUc+GmVPR6a Ci+6VOqkIoCqkUwj57lgGdKQIjQx+0u06pfgbe1vogvXORoNlyNPwu6WmvTrfcDJP9z0 1XLwuwTPvuVjzZx9V+OX4TMsFtAKrTTqj6LoLrrJOnCj4K9Ft/v1fivZhIXJS5K0JolM O/yw== 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=DDbFWUAdD66ccbGgAfeLRZAs/Smk+GVAFx7IHK4amAk=; b=Qlh5rXxzRjoiypf+CPPIoPBIUnCtIFwJ7rc3ow711PwxaodRSv0ckHjrsV6tI50KDz T9GEMypVJS0sAmp1W4WN3OKFltG/5jVKMpmbik5zDgHVgSCCMN4ccwrOd78N5d1cwDin VXim/SnETREN3hCpVJBuvE2wfSNnlD/soKUTd2Nx6G3dwSIACI0B70//h5FTJgCN1p1L IWVmUwbtz6qidLBQaMaV0iOf8h0xNDsjWQKjUG7sSSHEu6Vo15/WCOHO8gOsNZRYIy3Y MmUI6LXs3FgaE5VPOBpnqdG1vcPw2pHTAGvT2WWz5DUDNEuQnAOu9CIMjjhoe9y4/ged wR4Q== X-Gm-Message-State: AFqh2kqgdfz4BYw4+DLveuKw+PdFIGURHVDD7NgTEreO7rL6pZYio4Ts ZHUOZ30IyZsUln+J8vH41qFc0hcgxzuwrJyIreI= X-Google-Smtp-Source: AMrXdXuwCjNIGQk+TxvCKCwbaNS1HP82OeSo7pgaFM39/QFBEPtEFuOxcB/m3I+/65egM4Je+WJ34w== X-Received: by 2002:a67:b44a:0:b0:3b2:fe5e:6b73 with SMTP id c10-20020a67b44a000000b003b2fe5e6b73mr19424674vsm.22.1672769873102; Tue, 03 Jan 2023 10:17:53 -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 21/40] target/arm: Remove aarch64 check from aarch64_host_object_init Date: Tue, 3 Jan 2023 10:16:27 -0800 Message-Id: <20230103181646.55711-22-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::e2e; envelope-from=richard.henderson@linaro.org; helo=mail-vs1-xe2e.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672769966696100003 Content-Type: text/plain; charset="utf-8" Since kvm32 was removed, all kvm hosts support aarch64. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/cpu64.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 28b5a07244..668e979a24 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -1095,10 +1095,8 @@ static void aarch64_host_object_init(Object *obj) #if defined(CONFIG_KVM) ARMCPU *cpu =3D ARM_CPU(obj); kvm_arm_set_cpu_features_from_host(cpu); - if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { - aarch64_add_sve_properties(obj); - aarch64_add_pauth_properties(obj); - } + aarch64_add_sve_properties(obj); + aarch64_add_pauth_properties(obj); #elif defined(CONFIG_HVF) ARMCPU *cpu =3D ARM_CPU(obj); hvf_arm_set_cpu_features_from_host(cpu); --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672769937; cv=none; d=zohomail.com; s=zohoarc; b=gtwOaTeGQ09iR0S0P6Yzef0TQhe9wn319kLqREcx5W1DoeAj+UU1satBnX9ZmAgHz4FNx/eHE/Q9DNmIkNuGs/hMybVtz1m3UoZ4zgONEdPzDBVxpBRs2qmWXr0UAFouOXOuYRj8zPeY7dxfG/Vl0ui13UOUPlgz0BKjmdgl9tg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672769937; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Giw+JXSeEeudG8bVmdhTP6eAIZIod5pTf9XSXTJ4xZQ=; b=a30pRGaiCH2yRIjxdgtbNv+1yz6kHrQAq5IoAkS2Cpe48t7hmL+nEtr/Le0Jd6MWRUYRrCcOR4L1+hS8TvVkX7WZNex9mh6W6FevrkuMpWBQQMTHlxWSqmy3U820Acjpxc0vqLbgUPM81vj+3OmFqHiOT3eSX36yh9hBKxK63GA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672769937308199.10554922693098; Tue, 3 Jan 2023 10:18:57 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClre-0000GL-5Q; Tue, 03 Jan 2023 13:18:18 -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 1pClrL-0008Ok-Lx for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:10 -0500 Received: from mail-yw1-x1133.google.com ([2607:f8b0:4864:20::1133]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClrJ-0005Hh-Bf for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:59 -0500 Received: by mail-yw1-x1133.google.com with SMTP id 00721157ae682-46198b81e5eso447802937b3.4 for ; Tue, 03 Jan 2023 10:17:56 -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.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:55 -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=Giw+JXSeEeudG8bVmdhTP6eAIZIod5pTf9XSXTJ4xZQ=; b=f6LPjgglZp8gUIz/TSmNAR8uViyIdAMirRlVDGe3eoXKKkovb7eFw2p/sGXY6z6iym RWCAkfmnmwW5a2YkIg25Mxb0DAn4zEw1msjXxxfPRud/pZMK+VRSLa1Q2NCaDVUk+YnP RQSiXzG2kmU9sgFAW6j76ppNCg+ojkuVGSjNeubwjYukv8veOBVLjUON8VwS1oV/YSLA DKJSSHeKjQ8iCbd7R6N49gMNx1Q3NTgWPXgfXG6AHIpb6UTHIU4F8+GEnKr2MP0EaDuq s4711+h+/Zhg4g93IZloU71WRPl8kjUFgwaxUDbqsHuKMOGnsc7kQdofJbk4xoiC3Iys PDgg== 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=Giw+JXSeEeudG8bVmdhTP6eAIZIod5pTf9XSXTJ4xZQ=; b=wBrmL36S8o4eUdhaTE0cF018fbjlyUECqlZtChN96ugvY69XptdwpIuIFrZud1V43y 9Zl91Acxdw7swkXNEq3DAbRyMSLbumuk/UIOxfmaf+zd85F6B80j9mX8f1mqLssJKPgR zWth4978MkpAzBiMM7QKbWM3LY1xoUWgdlNZmb/+QI+PgHyJ9U8Ix3KQ8AT1c8qahJEo UNNUvBnBWE19W6F6VBmmYnMiaFobUCAmq9HrVdiLJNuG4vzcjNDg61GrW7HwMPqvdcyd G2fkjoG7hz2Rsx6z8CCq6BcJmu8xcInOoIS65aswshYJPD+fjt2inIiM/AiMc/jkmJfB ywIg== X-Gm-Message-State: AFqh2kqo/RFz0jit+fb5mgt6VdjeHPlxLuQTU99VZeVTQFx6SDJ1eC9t TDQk9IS/ZWOXqNFZ8O2G0lpQH7zBFuhh143yJqE= X-Google-Smtp-Source: AMrXdXs5WTWQ/mTOGpm+20aEI9lwBQ9G/I6/JD51IFswjJn2nxZQGAVFRIP9swK1ZOKOTjoa+FBdYA== X-Received: by 2002:a05:690c:250:b0:3e9:e55d:61e1 with SMTP id ba16-20020a05690c025000b003e9e55d61e1mr37195403ywb.8.1672769876170; Tue, 03 Jan 2023 10:17:56 -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 22/40] target/arm: Hoist feature and dtb_compatible from KVM, HVF Date: Tue, 3 Jan 2023 10:16:28 -0800 Message-Id: <20230103181646.55711-23-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::1133; envelope-from=richard.henderson@linaro.org; helo=mail-yw1-x1133.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672769938516100003 Content-Type: text/plain; charset="utf-8" These settings are generic and identical between the two host accelerators. Signed-off-by: Richard Henderson --- target/arm/cpu64.c | 23 ++++++++++++++++++++++- target/arm/hvf/hvf.c | 13 +------------ target/arm/kvm.c | 29 ++--------------------------- 3 files changed, 25 insertions(+), 40 deletions(-) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 668e979a24..75a88f9deb 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -1090,6 +1090,21 @@ static void aarch64_neoverse_n1_class_init(ARMCPUCla= ss *cpu) cpu->isar.reset_pmcr_el0 =3D 0x410c3000; } =20 +static void aarch64_host_class_init(ARMCPUClass *acc) +{ + /* + * While we don't know all the host details, we can assume at + * least v8 with VFPv4+Neon; this in turn implies most of the + * other feature bits. + */ + acc->dtb_compatible =3D "arm,arm-v8"; + set_class_feature(acc, ARM_FEATURE_V8); + set_class_feature(acc, ARM_FEATURE_NEON); + set_class_feature(acc, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(acc, ARM_FEATURE_AARCH64); + set_class_feature(acc, ARM_FEATURE_PMU); +} + static void aarch64_host_object_init(Object *obj) { #if defined(CONFIG_KVM) @@ -1122,8 +1137,12 @@ static bool aarch64_max_class_late_init(ARMCPUClass = *cpu, Error **errp) return true; } =20 - /* '-cpu max' for TCG: we currently do this as "A57 with extra things"= */ + /* + * '-cpu max' for TCG: we currently do this as "A57 with extra things" + * Retain the more generic dtb_compatible setting from host_class_init. + */ aarch64_a57_class_init(cpu); + cpu->dtb_compatible =3D "arm,arm-v8"; =20 /* * Reset MIDR so the guest doesn't mistake our 'max' CPU type for a re= al @@ -1316,10 +1335,12 @@ static const ARMCPUInfo aarch64_cpus[] =3D { .class_init =3D aarch64_a64fx_class_init, .object_init =3D aarch64_a64fx_object_init }, { .name =3D "max", + .class_init =3D aarch64_host_class_init, .class_late_init =3D aarch64_max_class_late_init, .object_init =3D aarch64_max_object_init }, #if defined(CONFIG_KVM) || defined(CONFIG_HVF) { .name =3D "host", + .class_init =3D aarch64_host_class_init, .object_init =3D aarch64_host_object_init }, #endif }; diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 278a4b2ede..8bb8b475cd 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -97,10 +97,8 @@ static HVFVTimer vtimer; =20 typedef struct ARMHostCPUFeatures { ARMISARegisters isar; - uint64_t features; uint64_t midr; uint32_t reset_sctlr; - const char *dtb_compatible; } ARMHostCPUFeatures; =20 static ARMHostCPUFeatures arm_host_cpu_features; @@ -489,13 +487,6 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFe= atures *ahcf) hv_vcpu_exit_t *exit; int i; =20 - ahcf->dtb_compatible =3D "arm,arm-v8"; - ahcf->features =3D (1ULL << ARM_FEATURE_V8) | - (1ULL << ARM_FEATURE_NEON) | - (1ULL << ARM_FEATURE_AARCH64) | - (1ULL << ARM_FEATURE_PMU) | - (1ULL << ARM_FEATURE_GENERIC_TIMER); - /* We set up a small vcpu to extract host registers */ =20 if (hv_vcpu_create(&fd, &exit, NULL) !=3D HV_SUCCESS) { @@ -532,7 +523,7 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFea= tures *ahcf) =20 void hvf_arm_set_cpu_features_from_host(ARMCPU *cpu) { - if (!arm_host_cpu_features.dtb_compatible) { + if (!arm_host_cpu_features.reset_sctlr) { if (!hvf_enabled() || !hvf_arm_get_host_cpu_features(&arm_host_cpu_features)) { /* @@ -544,9 +535,7 @@ void hvf_arm_set_cpu_features_from_host(ARMCPU *cpu) } } =20 - cpu->dtb_compatible =3D arm_host_cpu_features.dtb_compatible; cpu->isar =3D arm_host_cpu_features.isar; - cpu->env.features =3D arm_host_cpu_features.features; cpu->midr =3D arm_host_cpu_features.midr; cpu->reset_sctlr =3D arm_host_cpu_features.reset_sctlr; } diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 02a15c6013..ac164a6130 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -50,9 +50,7 @@ static bool cap_has_inject_ext_dabt; */ typedef struct ARMHostCPUFeatures { ARMISARegisters isar; - uint64_t features; uint32_t target; - const char *dtb_compatible; } ARMHostCPUFeatures; =20 static ARMHostCPUFeatures arm_host_cpu_features; @@ -1567,7 +1565,6 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUF= eatures *ahcf) int fdarray[3]; bool sve_supported; bool pmu_supported =3D false; - uint64_t features =3D 0; int err; =20 /* Old kernels may not know about the PREFERRED_TARGET ioctl: however @@ -1615,7 +1612,6 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUF= eatures *ahcf) } =20 ahcf->target =3D init.target; - ahcf->dtb_compatible =3D "arm,arm-v8"; =20 err =3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64pfr0, ARM64_SYS_REG(3, 0, 0, 4, 0)); @@ -1760,31 +1756,12 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCP= UFeatures *ahcf) =20 kvm_arm_destroy_scratch_host_vcpu(fdarray); =20 - if (err < 0) { - return false; - } - - /* - * We can assume any KVM supporting CPU is at least a v8 - * with VFPv4+Neon; this in turn implies most of the other - * feature bits. - */ - features |=3D 1ULL << ARM_FEATURE_V8; - features |=3D 1ULL << ARM_FEATURE_NEON; - features |=3D 1ULL << ARM_FEATURE_AARCH64; - features |=3D 1ULL << ARM_FEATURE_PMU; - features |=3D 1ULL << ARM_FEATURE_GENERIC_TIMER; - - ahcf->features =3D features; - - return true; + return !err; } =20 void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) { - CPUARMState *env =3D &cpu->env; - - if (!arm_host_cpu_features.dtb_compatible) { + if (!arm_host_cpu_features.isar.id_aa64pfr0) { if (!kvm_enabled() || !kvm_arm_get_host_cpu_features(&arm_host_cpu_features)) { /* We can't report this error yet, so flag that we need to @@ -1797,9 +1774,7 @@ void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) } =20 cpu->kvm_target =3D arm_host_cpu_features.target; - cpu->dtb_compatible =3D arm_host_cpu_features.dtb_compatible; cpu->isar =3D arm_host_cpu_features.isar; - env->features =3D arm_host_cpu_features.features; } =20 /** --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770384; cv=none; d=zohomail.com; s=zohoarc; b=nViQ8OTjH5UWnn+r2E6ZmWAYq52OGY/WpVYNdw9TyKIS0UZVMxivXwzFBg+YLq178fC5dOrFW+xc3kLmgMFW+/n9BZH8nr3+Gk1EdXjhs4F59p+/Va8XhkorqEZZPCts615ycswVCLtYqmqrvb4TgZplZFpiL6jv6m38Vemb4KY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770384; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/jTn1GxLrxhP97RklVZOWNe5snNH2L7l/ITGnN9gIBg=; b=WPSrKyG2Th+WSH3mBWv0LSNRGNCTmx7x1dBgjDzGGGE00Tv1pKLZsbrPpdVLxRi9EqmJpDiQAtt1G+CO+8uv37T+u2w6Gl/mFEVqz1o9ko4ZSgepeiMnjZDUyK5o4/bALGJ9NZsQfDmUedVDKCRFGWuISPpIl9kwKrwXODIPwzc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770384636568.5278242788737; Tue, 3 Jan 2023 10:26:24 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrd-0000DM-1n; Tue, 03 Jan 2023 13:18:17 -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 1pClrP-0008Os-Iw for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:10 -0500 Received: from mail-vk1-xa2f.google.com ([2607:f8b0:4864:20::a2f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClrM-0005IB-8g for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:02 -0500 Received: by mail-vk1-xa2f.google.com with SMTP id 6so15693479vkz.0 for ; Tue, 03 Jan 2023 10:17:59 -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.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:58 -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=/jTn1GxLrxhP97RklVZOWNe5snNH2L7l/ITGnN9gIBg=; b=SeY7fHclwugtpZzK/CFvRn4e6R915X/8lxcuXlILBpWBNZsnwx7VmXMLiK+Prx2U3Q rAoQn2uGq5uCx6wtmbq9PZKU1EHf9mD45KoiB19Nbf+PXHkJyF7vHi7W7BaFg9eKBurY sDJkYvrV4yPI1SdGG72uu14bkpMdIGdc+TxyI6rGxdLiFK+NVhPPEBBbSggGQnEJD222 XTNLgflbxpiluMcZF++Li2C7Lf3Twy8OZQ+wUr3SNLfexAB+KxNKk8pSB1Q96JXBkrbn IRz2+iPNc5L3fb3/ewZsunYCqbU11MB10zG17/nvC7aYC4vcV/cwb1aUD61ptcoE7wlE l1hg== 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=/jTn1GxLrxhP97RklVZOWNe5snNH2L7l/ITGnN9gIBg=; b=e+R49hPyOslyP5Uj60ZW3j0KN3jWZ0kJs80RuGkQfbFnYF/p/ZlAZXlO6P2Iv93LkH IYsL05pXmzBKHZANef/ZyjK0UNiJX7zJCeMmlekgdWHpQTpCWbyTEgWHfRyd+7cNh7rE FOQlhnlB2fx/i4ksUQC2Jc5alDz2vI7rrRc8F+G6obYRBBJ2RAuL3d18osnihe3Dy5Ax ayaHuRi0fDqoZOvNeo8fQQ4/5+Gq3wxvpzaEM55Br/IjiuX9vMxLjSqLuO55gUlxBOT5 pB7wVYW5uHw7YZRcQsFFo6LvY8nuN7otZTq4earuBSwuqRCx2WdFIZ+5OkuhqCsXbtCK yl/Q== X-Gm-Message-State: AFqh2kpLVB30PTUeW2Tqp7xuFypGFURmHT5uugHFu5vGiF+3D22tLduv QRW/YzEOXGwLolov4y+F6AYFoHBQ+unmZLKf9sc= X-Google-Smtp-Source: AMrXdXv3GUBf63Je2YGCIdmyx13dr+lKXOYhnUd44m32kW4Z06DA6g9YQ/6c684KXnsWr42SwbPzCQ== X-Received: by 2002:a1f:e284:0:b0:3d1:f1f1:b946 with SMTP id z126-20020a1fe284000000b003d1f1f1b946mr16211418vkg.6.1672769879073; Tue, 03 Jan 2023 10:17:59 -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 23/40] target/arm: Probe KVM host into ARMCPUClass Date: Tue, 3 Jan 2023 10:16:29 -0800 Message-Id: <20230103181646.55711-24-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::a2f; envelope-from=richard.henderson@linaro.org; helo=mail-vk1-xa2f.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770385495100001 Content-Type: text/plain; charset="utf-8" We can now store these values into ARMCPUClass instead of into a temporary ARMHostCPUFeatures structure. Signed-off-by: Richard Henderson --- target/arm/kvm_arm.h | 14 ++--- target/arm/cpu64.c | 18 +++++-- target/arm/kvm.c | 119 +++++++++++++++++-------------------------- 3 files changed, 69 insertions(+), 82 deletions(-) diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index 8efbe0cc4b..d426e24c53 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -140,13 +140,15 @@ void kvm_arm_destroy_scratch_host_vcpu(int *fdarray); uint32_t kvm_arm_sve_get_vls(CPUState *cs); =20 /** - * kvm_arm_set_cpu_features_from_host: - * @cpu: ARMCPU to set the features for + * kvm_arm_get_host_cpu_features: + * @acc: ARMCPUClass to fill in * - * Set up the ARMCPU struct fields up to match the information probed - * from the host CPU. + * Probe the capabilities of the host kernel's preferred CPU and fill + * in the ARMCPUClass struct accordingly. + * + * Returns true on success and false otherwise. */ -void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu); +bool kvm_arm_get_host_cpu_features(ARMCPUClass *acc, Error **errp); =20 /** * kvm_arm_add_vcpu_properties: @@ -245,7 +247,7 @@ static inline bool kvm_arm_steal_time_supported(void) /* * These functions should never actually be called without KVM support. */ -static inline void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) +static inline bool kvm_arm_get_host_cpu_features(ARMCPUClass *c, Error **e) { g_assert_not_reached(); } diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 75a88f9deb..a21bc39449 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -1105,11 +1105,21 @@ static void aarch64_host_class_init(ARMCPUClass *ac= c) set_class_feature(acc, ARM_FEATURE_PMU); } =20 +static bool aarch64_host_class_late_init(ARMCPUClass *acc, Error **errp) +{ + if (kvm_enabled()) { + return kvm_arm_get_host_cpu_features(acc, errp); + } + if (hvf_enabled()) { + return true; + } + error_setg(errp, "The 'host' CPU type can only be used with KVM or HVF= "); + return false; +} + static void aarch64_host_object_init(Object *obj) { #if defined(CONFIG_KVM) - ARMCPU *cpu =3D ARM_CPU(obj); - kvm_arm_set_cpu_features_from_host(cpu); aarch64_add_sve_properties(obj); aarch64_add_pauth_properties(obj); #elif defined(CONFIG_HVF) @@ -1134,7 +1144,8 @@ static bool aarch64_max_class_late_init(ARMCPUClass *= cpu, Error **errp) uint32_t u; =20 if (kvm_enabled() || hvf_enabled()) { - return true; + /* With KVM or HVF, '-cpu max' is identical to '-cpu host' */ + return aarch64_host_class_late_init(cpu, errp); } =20 /* @@ -1341,6 +1352,7 @@ static const ARMCPUInfo aarch64_cpus[] =3D { #if defined(CONFIG_KVM) || defined(CONFIG_HVF) { .name =3D "host", .class_init =3D aarch64_host_class_init, + .class_late_init =3D aarch64_host_class_late_init, .object_init =3D aarch64_host_object_init }, #endif }; diff --git a/target/arm/kvm.c b/target/arm/kvm.c index ac164a6130..85971df07c 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -44,17 +44,6 @@ static bool cap_has_mp_state; static bool cap_has_inject_serror_esr; static bool cap_has_inject_ext_dabt; =20 -/** - * ARMHostCPUFeatures: information about the host CPU (identified - * by asking the host kernel) - */ -typedef struct ARMHostCPUFeatures { - ARMISARegisters isar; - uint32_t target; -} ARMHostCPUFeatures; - -static ARMHostCPUFeatures arm_host_cpu_features; - /** * kvm_arm_vcpu_init: * @cs: CPUState @@ -1548,14 +1537,14 @@ static bool kvm_arm_pauth_supported(void) =20 /** * kvm_arm_get_host_cpu_features: - * @ahcf: ARMHostCPUClass to fill in + * @acc: ARMCPUClass to fill in * * Probe the capabilities of the host kernel's preferred CPU and fill - * in the ARMHostCPUClass struct accordingly. + * in the ARMCPUClass struct accordingly. * * Returns true on success and false otherwise. */ -static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) +bool kvm_arm_get_host_cpu_features(ARMCPUClass *acc, Error **errp) { /* Identify the feature bits corresponding to the host CPU, and * fill out the ARMHostCPUClass fields accordingly. To do this @@ -1608,12 +1597,14 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCP= UFeatures *ahcf) } =20 if (!kvm_arm_create_scratch_host_vcpu(cpus_to_try, fdarray, &init)) { + error_setg_errno(errp, "Failed to create host vcpu"); + acc->kvm_target =3D QEMU_KVM_ARM_TARGET_NONE; return false; } =20 - ahcf->target =3D init.target; + acc->kvm_target =3D init.target; =20 - err =3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64pfr0, + err =3D read_sys_reg64(fdarray[2], &acc->isar.id_aa64pfr0, ARM64_SYS_REG(3, 0, 0, 4, 0)); if (unlikely(err < 0)) { /* @@ -1632,26 +1623,26 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCP= UFeatures *ahcf) * ??? Either of these sounds like too much effort just * to work around running a modern host kernel. */ - ahcf->isar.id_aa64pfr0 =3D 0x00000011; /* EL1&0, AArch64 only */ + acc->isar.id_aa64pfr0 =3D 0x00000011; /* EL1&0, AArch64 only */ err =3D 0; } else { - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64pfr1, + err |=3D read_sys_reg64(fdarray[2], &acc->isar.id_aa64pfr1, ARM64_SYS_REG(3, 0, 0, 4, 1)); - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64smfr0, + err |=3D read_sys_reg64(fdarray[2], &acc->isar.id_aa64smfr0, ARM64_SYS_REG(3, 0, 0, 4, 5)); - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64dfr0, + err |=3D read_sys_reg64(fdarray[2], &acc->isar.id_aa64dfr0, ARM64_SYS_REG(3, 0, 0, 5, 0)); - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64dfr1, + err |=3D read_sys_reg64(fdarray[2], &acc->isar.id_aa64dfr1, ARM64_SYS_REG(3, 0, 0, 5, 1)); - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64isar0, + err |=3D read_sys_reg64(fdarray[2], &acc->isar.id_aa64isar0, ARM64_SYS_REG(3, 0, 0, 6, 0)); - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64isar1, + err |=3D read_sys_reg64(fdarray[2], &acc->isar.id_aa64isar1, ARM64_SYS_REG(3, 0, 0, 6, 1)); - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr0, + err |=3D read_sys_reg64(fdarray[2], &acc->isar.id_aa64mmfr0, ARM64_SYS_REG(3, 0, 0, 7, 0)); - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr1, + err |=3D read_sys_reg64(fdarray[2], &acc->isar.id_aa64mmfr1, ARM64_SYS_REG(3, 0, 0, 7, 1)); - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr2, + err |=3D read_sys_reg64(fdarray[2], &acc->isar.id_aa64mmfr2, ARM64_SYS_REG(3, 0, 0, 7, 2)); =20 /* @@ -1661,48 +1652,48 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCP= UFeatures *ahcf) * than skipping the reads and leaving 0, as we must avoid * considering the values in every case. */ - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr0, + err |=3D read_sys_reg32(fdarray[2], &acc->isar.id_pfr0, ARM64_SYS_REG(3, 0, 0, 1, 0)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr1, + err |=3D read_sys_reg32(fdarray[2], &acc->isar.id_pfr1, ARM64_SYS_REG(3, 0, 0, 1, 1)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_dfr0, + err |=3D read_sys_reg32(fdarray[2], &acc->isar.id_dfr0, ARM64_SYS_REG(3, 0, 0, 1, 2)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr0, + err |=3D read_sys_reg32(fdarray[2], &acc->isar.id_mmfr0, ARM64_SYS_REG(3, 0, 0, 1, 4)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr1, + err |=3D read_sys_reg32(fdarray[2], &acc->isar.id_mmfr1, ARM64_SYS_REG(3, 0, 0, 1, 5)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr2, + err |=3D read_sys_reg32(fdarray[2], &acc->isar.id_mmfr2, ARM64_SYS_REG(3, 0, 0, 1, 6)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr3, + err |=3D read_sys_reg32(fdarray[2], &acc->isar.id_mmfr3, ARM64_SYS_REG(3, 0, 0, 1, 7)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_isar0, + err |=3D read_sys_reg32(fdarray[2], &acc->isar.id_isar0, ARM64_SYS_REG(3, 0, 0, 2, 0)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_isar1, + err |=3D read_sys_reg32(fdarray[2], &acc->isar.id_isar1, ARM64_SYS_REG(3, 0, 0, 2, 1)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_isar2, + err |=3D read_sys_reg32(fdarray[2], &acc->isar.id_isar2, ARM64_SYS_REG(3, 0, 0, 2, 2)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_isar3, + err |=3D read_sys_reg32(fdarray[2], &acc->isar.id_isar3, ARM64_SYS_REG(3, 0, 0, 2, 3)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_isar4, + err |=3D read_sys_reg32(fdarray[2], &acc->isar.id_isar4, ARM64_SYS_REG(3, 0, 0, 2, 4)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_isar5, + err |=3D read_sys_reg32(fdarray[2], &acc->isar.id_isar5, ARM64_SYS_REG(3, 0, 0, 2, 5)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr4, + err |=3D read_sys_reg32(fdarray[2], &acc->isar.id_mmfr4, ARM64_SYS_REG(3, 0, 0, 2, 6)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_isar6, + err |=3D read_sys_reg32(fdarray[2], &acc->isar.id_isar6, ARM64_SYS_REG(3, 0, 0, 2, 7)); =20 - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.mvfr0, + err |=3D read_sys_reg32(fdarray[2], &acc->isar.mvfr0, ARM64_SYS_REG(3, 0, 0, 3, 0)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.mvfr1, + err |=3D read_sys_reg32(fdarray[2], &acc->isar.mvfr1, ARM64_SYS_REG(3, 0, 0, 3, 1)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.mvfr2, + err |=3D read_sys_reg32(fdarray[2], &acc->isar.mvfr2, ARM64_SYS_REG(3, 0, 0, 3, 2)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr2, + err |=3D read_sys_reg32(fdarray[2], &acc->isar.id_pfr2, ARM64_SYS_REG(3, 0, 0, 3, 4)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_dfr1, + err |=3D read_sys_reg32(fdarray[2], &acc->isar.id_dfr1, ARM64_SYS_REG(3, 0, 0, 3, 5)); - err |=3D read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr5, + err |=3D read_sys_reg32(fdarray[2], &acc->isar.id_mmfr5, ARM64_SYS_REG(3, 0, 0, 3, 6)); =20 /* @@ -1715,14 +1706,14 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCP= UFeatures *ahcf) * arch/arm64/kvm/sys_regs.c:trap_dbgidr() does. * We only do this if the CPU supports AArch32 at EL1. */ - if (FIELD_EX32(ahcf->isar.id_aa64pfr0, ID_AA64PFR0, EL1) >=3D 2) { - int wrps =3D FIELD_EX64(ahcf->isar.id_aa64dfr0, ID_AA64DFR0, W= RPS); - int brps =3D FIELD_EX64(ahcf->isar.id_aa64dfr0, ID_AA64DFR0, B= RPS); + if (FIELD_EX32(acc->isar.id_aa64pfr0, ID_AA64PFR0, EL1) >=3D 2) { + int wrps =3D FIELD_EX64(acc->isar.id_aa64dfr0, ID_AA64DFR0, WR= PS); + int brps =3D FIELD_EX64(acc->isar.id_aa64dfr0, ID_AA64DFR0, BR= PS); int ctx_cmps =3D - FIELD_EX64(ahcf->isar.id_aa64dfr0, ID_AA64DFR0, CTX_CMPS); + FIELD_EX64(acc->isar.id_aa64dfr0, ID_AA64DFR0, CTX_CMPS); int version =3D 6; /* ARMv8 debug architecture */ bool has_el3 =3D - !!FIELD_EX32(ahcf->isar.id_aa64pfr0, ID_AA64PFR0, EL3); + !!FIELD_EX32(acc->isar.id_aa64pfr0, ID_AA64PFR0, EL3); uint32_t dbgdidr =3D 0; =20 dbgdidr =3D FIELD_DP32(dbgdidr, DBGDIDR, WRPS, wrps); @@ -1732,12 +1723,12 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCP= UFeatures *ahcf) dbgdidr =3D FIELD_DP32(dbgdidr, DBGDIDR, NSUHD_IMP, has_el3); dbgdidr =3D FIELD_DP32(dbgdidr, DBGDIDR, SE_IMP, has_el3); dbgdidr |=3D (1 << 15); /* RES1 bit */ - ahcf->isar.dbgdidr =3D dbgdidr; + acc->isar.dbgdidr =3D dbgdidr; } =20 if (pmu_supported) { /* PMCR_EL0 is only accessible if the vCPU has feature PMU_V3 = */ - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.reset_pmcr_el0, + err |=3D read_sys_reg64(fdarray[2], &acc->isar.reset_pmcr_el0, ARM64_SYS_REG(3, 3, 9, 12, 0)); } =20 @@ -1749,7 +1740,7 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUF= eatures *ahcf) * enabled SVE support, which resulted in an error rather than= RAZ. * So only read the register if we set KVM_ARM_VCPU_SVE above. */ - err |=3D read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64zfr0, + err |=3D read_sys_reg64(fdarray[2], &acc->isar.id_aa64zfr0, ARM64_SYS_REG(3, 0, 0, 4, 4)); } } @@ -1759,24 +1750,6 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPU= Features *ahcf) return !err; } =20 -void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) -{ - if (!arm_host_cpu_features.isar.id_aa64pfr0) { - if (!kvm_enabled() || - !kvm_arm_get_host_cpu_features(&arm_host_cpu_features)) { - /* We can't report this error yet, so flag that we need to - * in arm_cpu_realizefn(). - */ - cpu->kvm_target =3D QEMU_KVM_ARM_TARGET_NONE; - cpu->host_cpu_probe_failed =3D true; - return; - } - } - - cpu->kvm_target =3D arm_host_cpu_features.target; - cpu->isar =3D arm_host_cpu_features.isar; -} - /** * kvm_arm_steal_time_supported: * --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770507; cv=none; d=zohomail.com; s=zohoarc; b=hlAs2G+L3xUFnnqYWxsx9TXCoYFUStpL6JU7jqremkYD1zC3BRQWeCxOCGpgkQ9f63q40DUA6ptor9JzgyN3vMGiOj/RKg8B6Rl68UmLYK4HfTPsywSYhDBaZCdEZ+sVb7mb51oQCBSIYnN2fa4ZV3H1Yduhm/1LScC8bPnCYxU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770507; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YMcPmZrXvRwclxq0TRDUHuwzEJ3xWsfRZYvLnaachU4=; b=KAFCiWVX2h25qlvBEMG3gxC1clyscdZcV29Rw1nStEv50E/ZLeA5j70hwPMLZxJ+rwAMa68WuczSDTB+1Sql7PAf9jG2quCPDEYbq47wibWTmJQO5Yac6OqcRzMd88oPHN7VnTEk2lMRu1I5IucdgJsGZxBAAThcqibrDvsp55U= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770507602840.734865315509; Tue, 3 Jan 2023 10:28:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrh-0000Pu-HF; Tue, 03 Jan 2023 13:18:21 -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 1pClrS-0008Oy-2c for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:10 -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 1pClrP-0005FO-6M for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:04 -0500 Received: by mail-vk1-xa2d.google.com with SMTP id f184so11693658vkh.2 for ; Tue, 03 Jan 2023 10:18:02 -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.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:18:01 -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=YMcPmZrXvRwclxq0TRDUHuwzEJ3xWsfRZYvLnaachU4=; b=SHjFVrXWpLrnEQ0o4p8q5ixJ45i80P5jPn9wIDpTIOxCQp+hKHk18iNC7ycAM5uycu t1JWPDh+yl8k8PsOokQV76wgqYf1uo52FCBdH0o9b5EFqQIzsXjQfUXfEm8eWojcVxDV Lf7S/2bKiUi07pVjIy+e2II3F1SmXCcWPjQ0rfr/yX/TymOrqUK/J4Aztm/BEVvSF5S0 mVZaabIDhLoYHQ4zV77jpGyWLCIg5DHUk+kW7Wz7BBLe4cz8aHKlwg0GG7qdK5AaAk0R tMKlyl3zc6pIVdRjeRpvbxQRcWHEI6wEzUoZ0AxEyoEI2rUuIpLs8zH8WNqCpIIQHcKT UpBg== 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=YMcPmZrXvRwclxq0TRDUHuwzEJ3xWsfRZYvLnaachU4=; b=61fKJ4QfxGxx4i7D9tg57HlRy1w55GHC8ojyUWq0rk20C+xmEvp4XFPcBkmAbzV4uI PsvtLL6KcFxfX2g5O17JGYVswiTldMALiWGlKNGSFdoayDl0ycXWPKksLQNOCQXERnt5 I4CAB2xJbx6ibx5egyIZOh5XByqnCnA7QOHOxb/yiXCP4ZERemUDW/ypDNh1kTogQg7Q 2wKnUPcc5W33lZM1YrcvU7Ap4VR9g99CoMoK0myKZL7tdphTTB3howGaHEbFygu0FEix peoxeyS9emPvw8s/pieGt14OSkczDEucOmTRdUuYbwhjOcLYJ/NLcK2modSzK5bDzelf ZSaw== X-Gm-Message-State: AFqh2kqERt6owHcfULYXyA5ru1byYu7vEgHr6/v5DCOBYHe5NPRcutRM 10uTqBgun19Xe+Kcbp8AjKLYT1bv3/7zOQahX+U= X-Google-Smtp-Source: AMrXdXuVod44xlv0JMXYoTe4kKGs1Do6jetMZt8F6wdq/uJNHvax/QzRgfyfi4yQLFL3nzhDGLIdPQ== X-Received: by 2002:a1f:2c57:0:b0:3af:2f14:6567 with SMTP id s84-20020a1f2c57000000b003af2f146567mr17359279vks.6.1672769881975; Tue, 03 Jan 2023 10:18:01 -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 24/40] target/arm/hvf: Probe host into ARMCPUClass Date: Tue, 3 Jan 2023 10:16:30 -0800 Message-Id: <20230103181646.55711-25-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; 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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770508295100001 Content-Type: text/plain; charset="utf-8" We can now store these values into ARMCPUClass instead of into a temporary ARMHostCPUFeatures structure. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/cpu.h | 5 ---- target/arm/hvf_arm.h | 2 +- target/arm/cpu.c | 13 ---------- target/arm/cpu64.c | 4 +-- target/arm/hvf/hvf.c | 59 +++++++++++--------------------------------- 5 files changed, 17 insertions(+), 66 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 0c5b942ed0..e8dd75b003 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -935,11 +935,6 @@ struct ArchCPU { /* KVM steal time */ OnOffAuto kvm_steal_time; =20 - /* True if we tried kvm_arm_host_cpu_features() during CPU instance_in= it - * and the probe failed (so we need to report the error in realize) - */ - bool host_cpu_probe_failed; - /* Specify the number of cores in this CPU cluster. Used for the L2CTLR * register. */ diff --git a/target/arm/hvf_arm.h b/target/arm/hvf_arm.h index 9a9d1a0bf5..c3b34ba31d 100644 --- a/target/arm/hvf_arm.h +++ b/target/arm/hvf_arm.h @@ -13,6 +13,6 @@ =20 #include "cpu.h" =20 -void hvf_arm_set_cpu_features_from_host(ARMCPU *cpu); +bool hvf_arm_get_host_cpu_features(ARMCPUClass *acc, Error **errp); =20 #endif diff --git a/target/arm/cpu.c b/target/arm/cpu.c index c58029fb4a..f4d8be6c4c 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1584,19 +1584,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Erro= r **errp) Error *local_err =3D NULL; bool no_aa32 =3D false; =20 - /* If we needed to query the host kernel for the CPU features - * then it's possible that might have failed in the initfn, but - * this is the first point where we can report it. - */ - if (cpu->host_cpu_probe_failed) { - if (!kvm_enabled() && !hvf_enabled()) { - error_setg(errp, "The 'host' CPU type can only be used with KV= M or HVF"); - } else { - error_setg(errp, "Failed to retrieve host CPU features"); - } - return; - } - #ifndef CONFIG_USER_ONLY /* The NVIC and M-profile CPU are two halves of a single piece of * hardware; trying to use one without the other is a command line diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index a21bc39449..f94f775585 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -1111,7 +1111,7 @@ static bool aarch64_host_class_late_init(ARMCPUClass = *acc, Error **errp) return kvm_arm_get_host_cpu_features(acc, errp); } if (hvf_enabled()) { - return true; + return hvf_arm_get_host_cpu_features(acc, errp); } error_setg(errp, "The 'host' CPU type can only be used with KVM or HVF= "); return false; @@ -1123,8 +1123,6 @@ static void aarch64_host_object_init(Object *obj) aarch64_add_sve_properties(obj); aarch64_add_pauth_properties(obj); #elif defined(CONFIG_HVF) - ARMCPU *cpu =3D ARM_CPU(obj); - hvf_arm_set_cpu_features_from_host(cpu); aarch64_add_pauth_properties(obj); #else g_assert_not_reached(); diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index 8bb8b475cd..d47159b9bf 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -95,14 +95,6 @@ typedef struct HVFVTimer { =20 static HVFVTimer vtimer; =20 -typedef struct ARMHostCPUFeatures { - ARMISARegisters isar; - uint64_t midr; - uint32_t reset_sctlr; -} ARMHostCPUFeatures; - -static ARMHostCPUFeatures arm_host_cpu_features; - struct hvf_reg_match { int reg; uint64_t offset; @@ -465,22 +457,21 @@ static uint64_t hvf_get_reg(CPUState *cpu, int rt) return val; } =20 -static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) +bool hvf_arm_get_host_cpu_features(ARMCPUClass *acc, Error **errp) { - ARMISARegisters host_isar =3D {}; const struct isar_regs { int reg; uint64_t *val; } regs[] =3D { - { HV_SYS_REG_ID_AA64PFR0_EL1, &host_isar.id_aa64pfr0 }, - { HV_SYS_REG_ID_AA64PFR1_EL1, &host_isar.id_aa64pfr1 }, - { HV_SYS_REG_ID_AA64DFR0_EL1, &host_isar.id_aa64dfr0 }, - { HV_SYS_REG_ID_AA64DFR1_EL1, &host_isar.id_aa64dfr1 }, - { HV_SYS_REG_ID_AA64ISAR0_EL1, &host_isar.id_aa64isar0 }, - { HV_SYS_REG_ID_AA64ISAR1_EL1, &host_isar.id_aa64isar1 }, - { HV_SYS_REG_ID_AA64MMFR0_EL1, &host_isar.id_aa64mmfr0 }, - { HV_SYS_REG_ID_AA64MMFR1_EL1, &host_isar.id_aa64mmfr1 }, - { HV_SYS_REG_ID_AA64MMFR2_EL1, &host_isar.id_aa64mmfr2 }, + { HV_SYS_REG_ID_AA64PFR0_EL1, &acc->isar.id_aa64pfr0 }, + { HV_SYS_REG_ID_AA64PFR1_EL1, &acc->isar.id_aa64pfr1 }, + { HV_SYS_REG_ID_AA64DFR0_EL1, &acc->isar.id_aa64dfr0 }, + { HV_SYS_REG_ID_AA64DFR1_EL1, &acc->isar.id_aa64dfr1 }, + { HV_SYS_REG_ID_AA64ISAR0_EL1, &acc->isar.id_aa64isar0 }, + { HV_SYS_REG_ID_AA64ISAR1_EL1, &acc->isar.id_aa64isar1 }, + { HV_SYS_REG_ID_AA64MMFR0_EL1, &acc->isar.id_aa64mmfr0 }, + { HV_SYS_REG_ID_AA64MMFR1_EL1, &acc->isar.id_aa64mmfr1 }, + { HV_SYS_REG_ID_AA64MMFR2_EL1, &acc->isar.id_aa64mmfr2 }, }; hv_vcpu_t fd; hv_return_t r =3D HV_SUCCESS; @@ -496,50 +487,30 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUF= eatures *ahcf) for (i =3D 0; i < ARRAY_SIZE(regs); i++) { r |=3D hv_vcpu_get_sys_reg(fd, regs[i].reg, regs[i].val); } - r |=3D hv_vcpu_get_sys_reg(fd, HV_SYS_REG_MIDR_EL1, &ahcf->midr); + r |=3D hv_vcpu_get_sys_reg(fd, HV_SYS_REG_MIDR_EL1, &acc->midr); r |=3D hv_vcpu_destroy(fd); =20 - ahcf->isar =3D host_isar; - /* * A scratch vCPU returns SCTLR 0, so let's fill our default with the = M1 * boot SCTLR from https://github.com/AsahiLinux/m1n1/issues/97 */ - ahcf->reset_sctlr =3D 0x30100180; + acc->reset_sctlr =3D 0x30100180; + /* * SPAN is disabled by default when SCTLR.SPAN=3D1. To improve compati= bility, * let's disable it on boot and then allow guest software to turn it o= n by * setting it to 0. */ - ahcf->reset_sctlr |=3D 0x00800000; + acc->reset_sctlr |=3D 0x00800000; =20 /* Make sure we don't advertise AArch32 support for EL0/EL1 */ - if ((host_isar.id_aa64pfr0 & 0xff) !=3D 0x11) { + if ((acc->isar.id_aa64pfr0 & 0xff) !=3D 0x11) { return false; } =20 return r =3D=3D HV_SUCCESS; } =20 -void hvf_arm_set_cpu_features_from_host(ARMCPU *cpu) -{ - if (!arm_host_cpu_features.reset_sctlr) { - if (!hvf_enabled() || - !hvf_arm_get_host_cpu_features(&arm_host_cpu_features)) { - /* - * We can't report this error yet, so flag that we need to - * in arm_cpu_realizefn(). - */ - cpu->host_cpu_probe_failed =3D true; - return; - } - } - - cpu->isar =3D arm_host_cpu_features.isar; - cpu->midr =3D arm_host_cpu_features.midr; - cpu->reset_sctlr =3D arm_host_cpu_features.reset_sctlr; -} - void hvf_arch_vcpu_destroy(CPUState *cpu) { } --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770456; cv=none; d=zohomail.com; s=zohoarc; b=GTDEjk+KeqClRmya2uTJFsCJpTcadFsjZQSoG842DGe69vX9HVtr4F6xVeXopFViFnJv/JXRticOoxgP6jhZ/Lgg4JmzxqIw6pT2S2Gp284Qnu6DFSapA1QOrH8nJghgngZ/zXXzp47ADdmeRTaghEhNV0tJsTCithtJMnsqh0s= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770456; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0cpI31q8puiq+k9BfPqvIkCRkk/xl8XaSMre9iCPsr0=; b=Jjyk7gdsXnwQ6vdJsfxzWDrQMXM+dQaSkGe5UdiOeJ4vo6EMeUof7eFCLg/hSCuIWxLbs6ZYZ41n0uEbH0GkJW/DA0eDNo1808lN1GGwxqCu9gwK8RopEMHptPnOm1WdlU3Ii4auIHommXnRCA42V40XhbdTqGsMFoSLXY63coY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770456089686.6840750468112; Tue, 3 Jan 2023 10:27:36 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClri-0000T7-HH; Tue, 03 Jan 2023 13:18:22 -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 1pClrT-0008P3-3w for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:10 -0500 Received: from mail-vs1-xe36.google.com ([2607:f8b0:4864:20::e36]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClrR-0005Ii-KZ for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:06 -0500 Received: by mail-vs1-xe36.google.com with SMTP id 3so32567815vsq.7 for ; Tue, 03 Jan 2023 10:18:05 -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.18.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:18:04 -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=0cpI31q8puiq+k9BfPqvIkCRkk/xl8XaSMre9iCPsr0=; b=sBGvtHN5Tao+Pzl4QK/QG95guKdeOvzOOlORTYmjvxJrWMarhCUIEjrH204YTgqCzk 1o33v5RMGFHLe29WvbC8ZOnO7X3f9xgp9SMMpDXsulKb+JMEKzUD80VVJRwnYhPCTjQR +M6Zqqh0QjzLYGWksF41xrHaeXGinBZsdukl88Ymy86MuuC+6d1m11kxygiaqInLGU+u d8z7VBtzM1G34T9xj6zrC729a+l/YfaGDw2wFaCcHv/9ZVs4uCyjBUvjsu2vQ2xYWvHE K50mju71bGd8+qqwO6/xE8G6cgHZyUIDiMmDswx14FaAWkWlpU3eGAS4o1bc2xDjjil6 XKng== 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=0cpI31q8puiq+k9BfPqvIkCRkk/xl8XaSMre9iCPsr0=; b=HPW3OvQ9xnksZ8CJtT/8s1REtVCgw8datZ84DzdGtal/keZFki3+gsneWRB8H7caN5 2UqshzM6nAlxVsqQzE+VUD0dbabp02GJdff55pQa9ak2WjWknWWuoDVFXBJk8Ebgy6ix PikDF/vc29zch8FeI43DNvnmsb5wXz8F8l1rnmXGvCcGy0iRPOejJ5sn0yNhJL1lXk2a j/w9oGzzJSgBkDdN112vmp8Y9mLltsQ978zFHWUynLPnW3exAlv6RI07SQZLps08VIGp x+SgAISqSGu0Pe2qvUKciv1ll0ES84zktNIC7kOJZgyTqLqT+Fw3VWIuG4teFBtzQ9AE hJqw== X-Gm-Message-State: AFqh2kqzR9rS/iaaWl9D4YdWvPzWAEjyNd06EXHrjSgRxsdCnG/XSilp GcRy78iUqNsZ3pfqRn8CH3zLKNN/ihh8k8XjTu8= X-Google-Smtp-Source: AMrXdXsA1G+BBk6tqktY/lrnFb/qn3IrJ7VYT4NKcw4u80Gk8UHP0VaF+A/TT5kjVDH3g0nEmbTqgQ== X-Received: by 2002:a67:e417:0:b0:3cc:e60c:64bc with SMTP id d23-20020a67e417000000b003cce60c64bcmr7693970vsf.34.1672769884529; Tue, 03 Jan 2023 10:18:04 -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 25/40] target/arm/hvf: Use offsetof in hvf_arm_get_host_cpu_features Date: Tue, 3 Jan 2023 10:16:31 -0800 Message-Id: <20230103181646.55711-26-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::e36; envelope-from=richard.henderson@linaro.org; helo=mail-vs1-xe36.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770457813100003 Content-Type: text/plain; charset="utf-8" Use an offsetof vs ARMCPUClass, which means that the regs[] array may be static const, and we can include midr in the list. Signed-off-by: Richard Henderson --- target/arm/hvf/hvf.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index d47159b9bf..362dd4ac2e 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -459,19 +459,29 @@ static uint64_t hvf_get_reg(CPUState *cpu, int rt) =20 bool hvf_arm_get_host_cpu_features(ARMCPUClass *acc, Error **errp) { - const struct isar_regs { - int reg; - uint64_t *val; + static const struct isar_regs { + int reg, offset; } regs[] =3D { - { HV_SYS_REG_ID_AA64PFR0_EL1, &acc->isar.id_aa64pfr0 }, - { HV_SYS_REG_ID_AA64PFR1_EL1, &acc->isar.id_aa64pfr1 }, - { HV_SYS_REG_ID_AA64DFR0_EL1, &acc->isar.id_aa64dfr0 }, - { HV_SYS_REG_ID_AA64DFR1_EL1, &acc->isar.id_aa64dfr1 }, - { HV_SYS_REG_ID_AA64ISAR0_EL1, &acc->isar.id_aa64isar0 }, - { HV_SYS_REG_ID_AA64ISAR1_EL1, &acc->isar.id_aa64isar1 }, - { HV_SYS_REG_ID_AA64MMFR0_EL1, &acc->isar.id_aa64mmfr0 }, - { HV_SYS_REG_ID_AA64MMFR1_EL1, &acc->isar.id_aa64mmfr1 }, - { HV_SYS_REG_ID_AA64MMFR2_EL1, &acc->isar.id_aa64mmfr2 }, + { HV_SYS_REG_ID_AA64PFR0_EL1, + offsetof(ARMCPUClass, isar.id_aa64pfr0) }, + { HV_SYS_REG_ID_AA64PFR1_EL1, + offsetof(ARMCPUClass, isar.id_aa64pfr1) }, + { HV_SYS_REG_ID_AA64DFR0_EL1, + offsetof(ARMCPUClass, isar.id_aa64dfr0) }, + { HV_SYS_REG_ID_AA64DFR1_EL1, + offsetof(ARMCPUClass, isar.id_aa64dfr1) }, + { HV_SYS_REG_ID_AA64ISAR0_EL1, + offsetof(ARMCPUClass, isar.id_aa64isar0) }, + { HV_SYS_REG_ID_AA64ISAR1_EL1, + offsetof(ARMCPUClass, isar.id_aa64isar1) }, + { HV_SYS_REG_ID_AA64MMFR0_EL1, + offsetof(ARMCPUClass, isar.id_aa64mmfr0) }, + { HV_SYS_REG_ID_AA64MMFR1_EL1, + offsetof(ARMCPUClass, isar.id_aa64mmfr1) }, + { HV_SYS_REG_ID_AA64MMFR2_EL1, + offsetof(ARMCPUClass, isar.id_aa64mmfr2) }, + { HV_SYS_REG_MIDR_EL1, + offsetof(ARMCPUClass, midr) }, }; hv_vcpu_t fd; hv_return_t r =3D HV_SUCCESS; @@ -485,9 +495,9 @@ bool hvf_arm_get_host_cpu_features(ARMCPUClass *acc, Er= ror **errp) } =20 for (i =3D 0; i < ARRAY_SIZE(regs); i++) { - r |=3D hv_vcpu_get_sys_reg(fd, regs[i].reg, regs[i].val); + uint64_t *p =3D (void *)acc + regs[i].offset; + r |=3D hv_vcpu_get_sys_reg(fd, regs[i].reg, p); } - r |=3D hv_vcpu_get_sys_reg(fd, HV_SYS_REG_MIDR_EL1, &acc->midr); r |=3D hv_vcpu_destroy(fd); =20 /* --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770413; cv=none; d=zohomail.com; s=zohoarc; b=PD4rFGPhytWr8CN24ohAOO6ndMHwx8qwKXmfcZBEYD0ZXSAgJwhVHMTacEGYBQ7wHECBofh/cCzrYJlYb700cKcjVxXSHa/DCZfWHARDkpVoGge92Nh3T+4u9Yx9V7YgTui/sTJlMrcwjzWDZPHuwW1YfIgGrfznRRP+xahY58U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770413; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=UudCQe6aaBu/DssdkCisyt5+2IhUcMmaavH5MxGn6CU=; b=jWZZhq0SmFqJndiyFw10tmGDVup1mjqfjQb/doKWA5pETzZWve1zEz4798Rkdr4gya1uyYqfKU1vatkEiVYS8O/tyl/nUUooAejAEhppmkrxnMEWvOIdldkHSu4uDcYUz8SPrsPHKVyWyqtUib+S1QgpIKU+8YOw3vhhtsxbXS4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770413705707.24402231355; Tue, 3 Jan 2023 10:26:53 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrf-0000I2-44; Tue, 03 Jan 2023 13:18:19 -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 1pClrZ-000076-Nc for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:14 -0500 Received: from mail-vk1-xa2a.google.com ([2607:f8b0:4864:20::a2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClrV-0005JJ-6O for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:13 -0500 Received: by mail-vk1-xa2a.google.com with SMTP id n205so8664092vkf.13 for ; Tue, 03 Jan 2023 10:18:08 -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.18.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:18:07 -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=UudCQe6aaBu/DssdkCisyt5+2IhUcMmaavH5MxGn6CU=; b=ECEPau6yOOUQt/L2GljuK3lwDDoNNoTY6q8Yqso+g9zLLpNy0n2bHrQjKg3St9QyGa rAFpKX3rn2sjbanzPk9KiT05/E1Euw3JfEoBL7Xbg+BJYrgcmUJ/juPdhaACLMk0/EYh FvfmIMBlpuyXGo1IatW2lXaBTkp9k/A0uIvQZfPTDeVURlsHeze1ghujGntZ9DrNgZLc Rk2efyoXEh4G8LD99wcgHO1AfEw/b9C/af3XujV8Wc/E9k2Vefvn6pX8UygQCXWYsPGV vDUhujPLDV4RWxKqJ9eqT7X4QnYjug53Ih+O+cesoBV13sYDpkFXtR6XVYoIYvA9J2ts JNNA== 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=UudCQe6aaBu/DssdkCisyt5+2IhUcMmaavH5MxGn6CU=; b=X/RrVTut4aAabm4qzrUoCXehMpaKakW6iRcqIbq2no7VyB41myqsM1bCihEZwFq/9V SmdoIQhkoWtIp07HxBbQx10uGg9bvsM5NyYxtTcrgo00L0TFH1YPyiKeBKuBtMARthto RKdSslpZ2z6cyEtKrj2+dO/WlEA1NTw0WVYqsva6Nl3vKMpL0yZgLH+agF7Hq6Z631wF C8mFZrfNnsxlGYL3yvDfYwZqfNpnx1qRXdI7U9p17wMrAe6sh6NGEt7xciPZfs+Ddgxk QTz7ZocZJyyWoby/m9BPBY8QptUSVbXLGXFaPK7unYFZNryQdkv6STAlFlsJwicU1yfN 6/gQ== X-Gm-Message-State: AFqh2kpu6EiGiWTJ2EFv27wW/XztFZYQnwV3458dWDoO6zlK/1VlsGMa zk34mX7h32fYoMxsHNcq72tGUUYD8NcxXSBp1XM= X-Google-Smtp-Source: AMrXdXvamc2UF5R4f7bwfXaVVwHZfqb9bKEQsQXtXPGoepN3NT9CRQhuS597628wKBaWplhZ/K8nWQ== X-Received: by 2002:a1f:320f:0:b0:3bc:b7f6:5fde with SMTP id y15-20020a1f320f000000b003bcb7f65fdemr19162894vky.4.1672769887715; Tue, 03 Jan 2023 10:18:07 -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 26/40] target/arm: Rename 'cpu' to 'acc' in class init functions Date: Tue, 3 Jan 2023 10:16:32 -0800 Message-Id: <20230103181646.55711-27-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::a2a; envelope-from=richard.henderson@linaro.org; helo=mail-vk1-xa2a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770415581100003 Content-Type: text/plain; charset="utf-8" These were previously left 'misnamed' to minimize the size of the patch. Rename them all in bulk with no other change. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/cpu64.c | 858 ++++++++++++++-------------- target/arm/cpu_tcg.c | 1260 +++++++++++++++++++++--------------------- 2 files changed, 1059 insertions(+), 1059 deletions(-) diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index f94f775585..6ad5f9e444 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -36,82 +36,82 @@ #include "hw/qdev-properties.h" #include "internals.h" =20 -static void aarch64_a35_class_init(ARMCPUClass *cpu) +static void aarch64_a35_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "arm,cortex-a35"; - set_class_feature(cpu, ARM_FEATURE_V8); - set_class_feature(cpu, ARM_FEATURE_NEON); - set_class_feature(cpu, ARM_FEATURE_GENERIC_TIMER); - set_class_feature(cpu, ARM_FEATURE_AARCH64); - set_class_feature(cpu, ARM_FEATURE_CBAR_RO); - set_class_feature(cpu, ARM_FEATURE_EL2); - set_class_feature(cpu, ARM_FEATURE_EL3); - set_class_feature(cpu, ARM_FEATURE_PMU); + acc->dtb_compatible =3D "arm,cortex-a35"; + set_class_feature(acc, ARM_FEATURE_V8); + set_class_feature(acc, ARM_FEATURE_NEON); + set_class_feature(acc, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(acc, ARM_FEATURE_AARCH64); + set_class_feature(acc, ARM_FEATURE_CBAR_RO); + set_class_feature(acc, ARM_FEATURE_EL2); + set_class_feature(acc, ARM_FEATURE_EL3); + set_class_feature(acc, ARM_FEATURE_PMU); =20 /* From B2.2 AArch64 identification registers. */ - cpu->midr =3D 0x411fd040; - cpu->revidr =3D 0; - cpu->ctr =3D 0x84448004; - cpu->isar.id_pfr0 =3D 0x00000131; - cpu->isar.id_pfr1 =3D 0x00011011; - cpu->isar.id_dfr0 =3D 0x03010066; - cpu->id_afr0 =3D 0; - cpu->isar.id_mmfr0 =3D 0x10201105; - cpu->isar.id_mmfr1 =3D 0x40000000; - cpu->isar.id_mmfr2 =3D 0x01260000; - cpu->isar.id_mmfr3 =3D 0x02102211; - cpu->isar.id_isar0 =3D 0x02101110; - cpu->isar.id_isar1 =3D 0x13112111; - cpu->isar.id_isar2 =3D 0x21232042; - cpu->isar.id_isar3 =3D 0x01112131; - cpu->isar.id_isar4 =3D 0x00011142; - cpu->isar.id_isar5 =3D 0x00011121; - cpu->isar.id_aa64pfr0 =3D 0x00002222; - cpu->isar.id_aa64pfr1 =3D 0; - cpu->isar.id_aa64dfr0 =3D 0x10305106; - cpu->isar.id_aa64dfr1 =3D 0; - cpu->isar.id_aa64isar0 =3D 0x00011120; - cpu->isar.id_aa64isar1 =3D 0; - cpu->isar.id_aa64mmfr0 =3D 0x00101122; - cpu->isar.id_aa64mmfr1 =3D 0; - cpu->clidr =3D 0x0a200023; - cpu->dcz_blocksize =3D 4; + acc->midr =3D 0x411fd040; + acc->revidr =3D 0; + acc->ctr =3D 0x84448004; + acc->isar.id_pfr0 =3D 0x00000131; + acc->isar.id_pfr1 =3D 0x00011011; + acc->isar.id_dfr0 =3D 0x03010066; + acc->id_afr0 =3D 0; + acc->isar.id_mmfr0 =3D 0x10201105; + acc->isar.id_mmfr1 =3D 0x40000000; + acc->isar.id_mmfr2 =3D 0x01260000; + acc->isar.id_mmfr3 =3D 0x02102211; + acc->isar.id_isar0 =3D 0x02101110; + acc->isar.id_isar1 =3D 0x13112111; + acc->isar.id_isar2 =3D 0x21232042; + acc->isar.id_isar3 =3D 0x01112131; + acc->isar.id_isar4 =3D 0x00011142; + acc->isar.id_isar5 =3D 0x00011121; + acc->isar.id_aa64pfr0 =3D 0x00002222; + acc->isar.id_aa64pfr1 =3D 0; + acc->isar.id_aa64dfr0 =3D 0x10305106; + acc->isar.id_aa64dfr1 =3D 0; + acc->isar.id_aa64isar0 =3D 0x00011120; + acc->isar.id_aa64isar1 =3D 0; + acc->isar.id_aa64mmfr0 =3D 0x00101122; + acc->isar.id_aa64mmfr1 =3D 0; + acc->clidr =3D 0x0a200023; + acc->dcz_blocksize =3D 4; =20 /* From B2.4 AArch64 Virtual Memory control registers */ - cpu->reset_sctlr =3D 0x00c50838; + acc->reset_sctlr =3D 0x00c50838; =20 /* From B2.10 AArch64 performance monitor registers */ - cpu->isar.reset_pmcr_el0 =3D 0x410a3000; + acc->isar.reset_pmcr_el0 =3D 0x410a3000; =20 /* From B2.29 Cache ID registers */ - cpu->ccsidr[0] =3D 0x700fe01a; /* 32KB L1 dcache */ - cpu->ccsidr[1] =3D 0x201fe00a; /* 32KB L1 icache */ - cpu->ccsidr[2] =3D 0x703fe03a; /* 512KB L2 cache */ + acc->ccsidr[0] =3D 0x700fe01a; /* 32KB L1 dcache */ + acc->ccsidr[1] =3D 0x201fe00a; /* 32KB L1 icache */ + acc->ccsidr[2] =3D 0x703fe03a; /* 512KB L2 cache */ =20 /* From B3.5 VGIC Type register */ - cpu->gic_num_lrs =3D 4; - cpu->gic_vpribits =3D 5; - cpu->gic_vprebits =3D 5; - cpu->gic_pribits =3D 5; + acc->gic_num_lrs =3D 4; + acc->gic_vpribits =3D 5; + acc->gic_vprebits =3D 5; + acc->gic_pribits =3D 5; =20 /* From C6.4 Debug ID Register */ - cpu->isar.dbgdidr =3D 0x3516d000; + acc->isar.dbgdidr =3D 0x3516d000; /* From C6.5 Debug Device ID Register */ - cpu->isar.dbgdevid =3D 0x00110f13; + acc->isar.dbgdevid =3D 0x00110f13; /* From C6.6 Debug Device ID Register 1 */ - cpu->isar.dbgdevid1 =3D 0x2; + acc->isar.dbgdevid1 =3D 0x2; =20 /* From Cortex-A35 SIMD and Floating-point Support r1p0 */ /* From 3.2 AArch32 register summary */ - cpu->reset_fpsid =3D 0x41034043; + acc->reset_fpsid =3D 0x41034043; =20 /* From 2.2 AArch64 register summary */ - cpu->isar.mvfr0 =3D 0x10110222; - cpu->isar.mvfr1 =3D 0x12111111; - cpu->isar.mvfr2 =3D 0x00000043; + acc->isar.mvfr0 =3D 0x10110222; + acc->isar.mvfr1 =3D 0x12111111; + acc->isar.mvfr2 =3D 0x00000043; =20 /* These values are the same with A53/A57/A72. */ - define_cortex_a72_a57_a53_cp_reginfo(cpu); + define_cortex_a72_a57_a53_cp_reginfo(acc); } =20 void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) @@ -676,338 +676,338 @@ void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **err= p) cpu->isar.id_aa64mmfr0 =3D t; } =20 -static void aarch64_a57_class_init(ARMCPUClass *cpu) +static void aarch64_a57_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "arm,cortex-a57"; - set_class_feature(cpu, ARM_FEATURE_V8); - set_class_feature(cpu, ARM_FEATURE_NEON); - set_class_feature(cpu, ARM_FEATURE_GENERIC_TIMER); - set_class_feature(cpu, ARM_FEATURE_AARCH64); - set_class_feature(cpu, ARM_FEATURE_CBAR_RO); - set_class_feature(cpu, ARM_FEATURE_EL2); - set_class_feature(cpu, ARM_FEATURE_EL3); - set_class_feature(cpu, ARM_FEATURE_PMU); - cpu->kvm_target =3D QEMU_KVM_ARM_TARGET_CORTEX_A57; - cpu->midr =3D 0x411fd070; - cpu->revidr =3D 0x00000000; - cpu->reset_fpsid =3D 0x41034070; - cpu->isar.mvfr0 =3D 0x10110222; - cpu->isar.mvfr1 =3D 0x12111111; - cpu->isar.mvfr2 =3D 0x00000043; - cpu->ctr =3D 0x8444c004; - cpu->reset_sctlr =3D 0x00c50838; - cpu->isar.id_pfr0 =3D 0x00000131; - cpu->isar.id_pfr1 =3D 0x00011011; - cpu->isar.id_dfr0 =3D 0x03010066; - cpu->id_afr0 =3D 0x00000000; - cpu->isar.id_mmfr0 =3D 0x10101105; - cpu->isar.id_mmfr1 =3D 0x40000000; - cpu->isar.id_mmfr2 =3D 0x01260000; - cpu->isar.id_mmfr3 =3D 0x02102211; - cpu->isar.id_isar0 =3D 0x02101110; - cpu->isar.id_isar1 =3D 0x13112111; - cpu->isar.id_isar2 =3D 0x21232042; - cpu->isar.id_isar3 =3D 0x01112131; - cpu->isar.id_isar4 =3D 0x00011142; - cpu->isar.id_isar5 =3D 0x00011121; - cpu->isar.id_isar6 =3D 0; - cpu->isar.id_aa64pfr0 =3D 0x00002222; - cpu->isar.id_aa64dfr0 =3D 0x10305106; - cpu->isar.id_aa64isar0 =3D 0x00011120; - cpu->isar.id_aa64mmfr0 =3D 0x00001124; - cpu->isar.dbgdidr =3D 0x3516d000; - cpu->isar.dbgdevid =3D 0x01110f13; - cpu->isar.dbgdevid1 =3D 0x2; - cpu->isar.reset_pmcr_el0 =3D 0x41013000; - cpu->clidr =3D 0x0a200023; - cpu->ccsidr[0] =3D 0x701fe00a; /* 32KB L1 dcache */ - cpu->ccsidr[1] =3D 0x201fe012; /* 48KB L1 icache */ - cpu->ccsidr[2] =3D 0x70ffe07a; /* 2048KB L2 cache */ - cpu->dcz_blocksize =3D 4; /* 64 bytes */ - cpu->gic_num_lrs =3D 4; - cpu->gic_vpribits =3D 5; - cpu->gic_vprebits =3D 5; - cpu->gic_pribits =3D 5; - define_cortex_a72_a57_a53_cp_reginfo(cpu); + acc->dtb_compatible =3D "arm,cortex-a57"; + set_class_feature(acc, ARM_FEATURE_V8); + set_class_feature(acc, ARM_FEATURE_NEON); + set_class_feature(acc, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(acc, ARM_FEATURE_AARCH64); + set_class_feature(acc, ARM_FEATURE_CBAR_RO); + set_class_feature(acc, ARM_FEATURE_EL2); + set_class_feature(acc, ARM_FEATURE_EL3); + set_class_feature(acc, ARM_FEATURE_PMU); + acc->kvm_target =3D QEMU_KVM_ARM_TARGET_CORTEX_A57; + acc->midr =3D 0x411fd070; + acc->revidr =3D 0x00000000; + acc->reset_fpsid =3D 0x41034070; + acc->isar.mvfr0 =3D 0x10110222; + acc->isar.mvfr1 =3D 0x12111111; + acc->isar.mvfr2 =3D 0x00000043; + acc->ctr =3D 0x8444c004; + acc->reset_sctlr =3D 0x00c50838; + acc->isar.id_pfr0 =3D 0x00000131; + acc->isar.id_pfr1 =3D 0x00011011; + acc->isar.id_dfr0 =3D 0x03010066; + acc->id_afr0 =3D 0x00000000; + acc->isar.id_mmfr0 =3D 0x10101105; + acc->isar.id_mmfr1 =3D 0x40000000; + acc->isar.id_mmfr2 =3D 0x01260000; + acc->isar.id_mmfr3 =3D 0x02102211; + acc->isar.id_isar0 =3D 0x02101110; + acc->isar.id_isar1 =3D 0x13112111; + acc->isar.id_isar2 =3D 0x21232042; + acc->isar.id_isar3 =3D 0x01112131; + acc->isar.id_isar4 =3D 0x00011142; + acc->isar.id_isar5 =3D 0x00011121; + acc->isar.id_isar6 =3D 0; + acc->isar.id_aa64pfr0 =3D 0x00002222; + acc->isar.id_aa64dfr0 =3D 0x10305106; + acc->isar.id_aa64isar0 =3D 0x00011120; + acc->isar.id_aa64mmfr0 =3D 0x00001124; + acc->isar.dbgdidr =3D 0x3516d000; + acc->isar.dbgdevid =3D 0x01110f13; + acc->isar.dbgdevid1 =3D 0x2; + acc->isar.reset_pmcr_el0 =3D 0x41013000; + acc->clidr =3D 0x0a200023; + acc->ccsidr[0] =3D 0x701fe00a; /* 32KB L1 dcache */ + acc->ccsidr[1] =3D 0x201fe012; /* 48KB L1 icache */ + acc->ccsidr[2] =3D 0x70ffe07a; /* 2048KB L2 cache */ + acc->dcz_blocksize =3D 4; /* 64 bytes */ + acc->gic_num_lrs =3D 4; + acc->gic_vpribits =3D 5; + acc->gic_vprebits =3D 5; + acc->gic_pribits =3D 5; + define_cortex_a72_a57_a53_cp_reginfo(acc); } =20 -static void aarch64_a53_class_init(ARMCPUClass *cpu) +static void aarch64_a53_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "arm,cortex-a53"; - set_class_feature(cpu, ARM_FEATURE_V8); - set_class_feature(cpu, ARM_FEATURE_NEON); - set_class_feature(cpu, ARM_FEATURE_GENERIC_TIMER); - set_class_feature(cpu, ARM_FEATURE_AARCH64); - set_class_feature(cpu, ARM_FEATURE_CBAR_RO); - set_class_feature(cpu, ARM_FEATURE_EL2); - set_class_feature(cpu, ARM_FEATURE_EL3); - set_class_feature(cpu, ARM_FEATURE_PMU); - cpu->kvm_target =3D QEMU_KVM_ARM_TARGET_CORTEX_A53; - cpu->midr =3D 0x410fd034; - cpu->revidr =3D 0x00000000; - cpu->reset_fpsid =3D 0x41034070; - cpu->isar.mvfr0 =3D 0x10110222; - cpu->isar.mvfr1 =3D 0x12111111; - cpu->isar.mvfr2 =3D 0x00000043; - cpu->ctr =3D 0x84448004; /* L1Ip =3D VIPT */ - cpu->reset_sctlr =3D 0x00c50838; - cpu->isar.id_pfr0 =3D 0x00000131; - cpu->isar.id_pfr1 =3D 0x00011011; - cpu->isar.id_dfr0 =3D 0x03010066; - cpu->id_afr0 =3D 0x00000000; - cpu->isar.id_mmfr0 =3D 0x10101105; - cpu->isar.id_mmfr1 =3D 0x40000000; - cpu->isar.id_mmfr2 =3D 0x01260000; - cpu->isar.id_mmfr3 =3D 0x02102211; - cpu->isar.id_isar0 =3D 0x02101110; - cpu->isar.id_isar1 =3D 0x13112111; - cpu->isar.id_isar2 =3D 0x21232042; - cpu->isar.id_isar3 =3D 0x01112131; - cpu->isar.id_isar4 =3D 0x00011142; - cpu->isar.id_isar5 =3D 0x00011121; - cpu->isar.id_isar6 =3D 0; - cpu->isar.id_aa64pfr0 =3D 0x00002222; - cpu->isar.id_aa64dfr0 =3D 0x10305106; - cpu->isar.id_aa64isar0 =3D 0x00011120; - cpu->isar.id_aa64mmfr0 =3D 0x00001122; /* 40 bit physical addr */ - cpu->isar.dbgdidr =3D 0x3516d000; - cpu->isar.dbgdevid =3D 0x00110f13; - cpu->isar.dbgdevid1 =3D 0x1; - cpu->isar.reset_pmcr_el0 =3D 0x41033000; - cpu->clidr =3D 0x0a200023; - cpu->ccsidr[0] =3D 0x700fe01a; /* 32KB L1 dcache */ - cpu->ccsidr[1] =3D 0x201fe00a; /* 32KB L1 icache */ - cpu->ccsidr[2] =3D 0x707fe07a; /* 1024KB L2 cache */ - cpu->dcz_blocksize =3D 4; /* 64 bytes */ - cpu->gic_num_lrs =3D 4; - cpu->gic_vpribits =3D 5; - cpu->gic_vprebits =3D 5; - cpu->gic_pribits =3D 5; - define_cortex_a72_a57_a53_cp_reginfo(cpu); + acc->dtb_compatible =3D "arm,cortex-a53"; + set_class_feature(acc, ARM_FEATURE_V8); + set_class_feature(acc, ARM_FEATURE_NEON); + set_class_feature(acc, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(acc, ARM_FEATURE_AARCH64); + set_class_feature(acc, ARM_FEATURE_CBAR_RO); + set_class_feature(acc, ARM_FEATURE_EL2); + set_class_feature(acc, ARM_FEATURE_EL3); + set_class_feature(acc, ARM_FEATURE_PMU); + acc->kvm_target =3D QEMU_KVM_ARM_TARGET_CORTEX_A53; + acc->midr =3D 0x410fd034; + acc->revidr =3D 0x00000000; + acc->reset_fpsid =3D 0x41034070; + acc->isar.mvfr0 =3D 0x10110222; + acc->isar.mvfr1 =3D 0x12111111; + acc->isar.mvfr2 =3D 0x00000043; + acc->ctr =3D 0x84448004; /* L1Ip =3D VIPT */ + acc->reset_sctlr =3D 0x00c50838; + acc->isar.id_pfr0 =3D 0x00000131; + acc->isar.id_pfr1 =3D 0x00011011; + acc->isar.id_dfr0 =3D 0x03010066; + acc->id_afr0 =3D 0x00000000; + acc->isar.id_mmfr0 =3D 0x10101105; + acc->isar.id_mmfr1 =3D 0x40000000; + acc->isar.id_mmfr2 =3D 0x01260000; + acc->isar.id_mmfr3 =3D 0x02102211; + acc->isar.id_isar0 =3D 0x02101110; + acc->isar.id_isar1 =3D 0x13112111; + acc->isar.id_isar2 =3D 0x21232042; + acc->isar.id_isar3 =3D 0x01112131; + acc->isar.id_isar4 =3D 0x00011142; + acc->isar.id_isar5 =3D 0x00011121; + acc->isar.id_isar6 =3D 0; + acc->isar.id_aa64pfr0 =3D 0x00002222; + acc->isar.id_aa64dfr0 =3D 0x10305106; + acc->isar.id_aa64isar0 =3D 0x00011120; + acc->isar.id_aa64mmfr0 =3D 0x00001122; /* 40 bit physical addr */ + acc->isar.dbgdidr =3D 0x3516d000; + acc->isar.dbgdevid =3D 0x00110f13; + acc->isar.dbgdevid1 =3D 0x1; + acc->isar.reset_pmcr_el0 =3D 0x41033000; + acc->clidr =3D 0x0a200023; + acc->ccsidr[0] =3D 0x700fe01a; /* 32KB L1 dcache */ + acc->ccsidr[1] =3D 0x201fe00a; /* 32KB L1 icache */ + acc->ccsidr[2] =3D 0x707fe07a; /* 1024KB L2 cache */ + acc->dcz_blocksize =3D 4; /* 64 bytes */ + acc->gic_num_lrs =3D 4; + acc->gic_vpribits =3D 5; + acc->gic_vprebits =3D 5; + acc->gic_pribits =3D 5; + define_cortex_a72_a57_a53_cp_reginfo(acc); } =20 -static void aarch64_a55_class_init(ARMCPUClass *cpu) +static void aarch64_a55_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "arm,cortex-a55"; - set_class_feature(cpu, ARM_FEATURE_V8); - set_class_feature(cpu, ARM_FEATURE_NEON); - set_class_feature(cpu, ARM_FEATURE_GENERIC_TIMER); - set_class_feature(cpu, ARM_FEATURE_AARCH64); - set_class_feature(cpu, ARM_FEATURE_CBAR_RO); - set_class_feature(cpu, ARM_FEATURE_EL2); - set_class_feature(cpu, ARM_FEATURE_EL3); - set_class_feature(cpu, ARM_FEATURE_PMU); + acc->dtb_compatible =3D "arm,cortex-a55"; + set_class_feature(acc, ARM_FEATURE_V8); + set_class_feature(acc, ARM_FEATURE_NEON); + set_class_feature(acc, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(acc, ARM_FEATURE_AARCH64); + set_class_feature(acc, ARM_FEATURE_CBAR_RO); + set_class_feature(acc, ARM_FEATURE_EL2); + set_class_feature(acc, ARM_FEATURE_EL3); + set_class_feature(acc, ARM_FEATURE_PMU); =20 /* Ordered by B2.4 AArch64 registers by functional group */ - cpu->clidr =3D 0x82000023; - cpu->ctr =3D 0x84448004; /* L1Ip =3D VIPT */ - cpu->dcz_blocksize =3D 4; /* 64 bytes */ - cpu->isar.id_aa64dfr0 =3D 0x0000000010305408ull; - cpu->isar.id_aa64isar0 =3D 0x0000100010211120ull; - cpu->isar.id_aa64isar1 =3D 0x0000000000100001ull; - cpu->isar.id_aa64mmfr0 =3D 0x0000000000101122ull; - cpu->isar.id_aa64mmfr1 =3D 0x0000000010212122ull; - cpu->isar.id_aa64mmfr2 =3D 0x0000000000001011ull; - cpu->isar.id_aa64pfr0 =3D 0x0000000010112222ull; - cpu->isar.id_aa64pfr1 =3D 0x0000000000000010ull; - cpu->id_afr0 =3D 0x00000000; - cpu->isar.id_dfr0 =3D 0x04010088; - cpu->isar.id_isar0 =3D 0x02101110; - cpu->isar.id_isar1 =3D 0x13112111; - cpu->isar.id_isar2 =3D 0x21232042; - cpu->isar.id_isar3 =3D 0x01112131; - cpu->isar.id_isar4 =3D 0x00011142; - cpu->isar.id_isar5 =3D 0x01011121; - cpu->isar.id_isar6 =3D 0x00000010; - cpu->isar.id_mmfr0 =3D 0x10201105; - cpu->isar.id_mmfr1 =3D 0x40000000; - cpu->isar.id_mmfr2 =3D 0x01260000; - cpu->isar.id_mmfr3 =3D 0x02122211; - cpu->isar.id_mmfr4 =3D 0x00021110; - cpu->isar.id_pfr0 =3D 0x10010131; - cpu->isar.id_pfr1 =3D 0x00011011; - cpu->isar.id_pfr2 =3D 0x00000011; - cpu->midr =3D 0x412FD050; /* r2p0 */ - cpu->revidr =3D 0; + acc->clidr =3D 0x82000023; + acc->ctr =3D 0x84448004; /* L1Ip =3D VIPT */ + acc->dcz_blocksize =3D 4; /* 64 bytes */ + acc->isar.id_aa64dfr0 =3D 0x0000000010305408ull; + acc->isar.id_aa64isar0 =3D 0x0000100010211120ull; + acc->isar.id_aa64isar1 =3D 0x0000000000100001ull; + acc->isar.id_aa64mmfr0 =3D 0x0000000000101122ull; + acc->isar.id_aa64mmfr1 =3D 0x0000000010212122ull; + acc->isar.id_aa64mmfr2 =3D 0x0000000000001011ull; + acc->isar.id_aa64pfr0 =3D 0x0000000010112222ull; + acc->isar.id_aa64pfr1 =3D 0x0000000000000010ull; + acc->id_afr0 =3D 0x00000000; + acc->isar.id_dfr0 =3D 0x04010088; + acc->isar.id_isar0 =3D 0x02101110; + acc->isar.id_isar1 =3D 0x13112111; + acc->isar.id_isar2 =3D 0x21232042; + acc->isar.id_isar3 =3D 0x01112131; + acc->isar.id_isar4 =3D 0x00011142; + acc->isar.id_isar5 =3D 0x01011121; + acc->isar.id_isar6 =3D 0x00000010; + acc->isar.id_mmfr0 =3D 0x10201105; + acc->isar.id_mmfr1 =3D 0x40000000; + acc->isar.id_mmfr2 =3D 0x01260000; + acc->isar.id_mmfr3 =3D 0x02122211; + acc->isar.id_mmfr4 =3D 0x00021110; + acc->isar.id_pfr0 =3D 0x10010131; + acc->isar.id_pfr1 =3D 0x00011011; + acc->isar.id_pfr2 =3D 0x00000011; + acc->midr =3D 0x412FD050; /* r2p0 */ + acc->revidr =3D 0; =20 /* From B2.23 CCSIDR_EL1 */ - cpu->ccsidr[0] =3D 0x700fe01a; /* 32KB L1 dcache */ - cpu->ccsidr[1] =3D 0x200fe01a; /* 32KB L1 icache */ - cpu->ccsidr[2] =3D 0x703fe07a; /* 512KB L2 cache */ + acc->ccsidr[0] =3D 0x700fe01a; /* 32KB L1 dcache */ + acc->ccsidr[1] =3D 0x200fe01a; /* 32KB L1 icache */ + acc->ccsidr[2] =3D 0x703fe07a; /* 512KB L2 cache */ =20 /* From B2.96 SCTLR_EL3 */ - cpu->reset_sctlr =3D 0x30c50838; + acc->reset_sctlr =3D 0x30c50838; =20 /* From B4.45 ICH_VTR_EL2 */ - cpu->gic_num_lrs =3D 4; - cpu->gic_vpribits =3D 5; - cpu->gic_vprebits =3D 5; - cpu->gic_pribits =3D 5; + acc->gic_num_lrs =3D 4; + acc->gic_vpribits =3D 5; + acc->gic_vprebits =3D 5; + acc->gic_pribits =3D 5; =20 - cpu->isar.mvfr0 =3D 0x10110222; - cpu->isar.mvfr1 =3D 0x13211111; - cpu->isar.mvfr2 =3D 0x00000043; + acc->isar.mvfr0 =3D 0x10110222; + acc->isar.mvfr1 =3D 0x13211111; + acc->isar.mvfr2 =3D 0x00000043; =20 /* From D5.4 AArch64 PMU register summary */ - cpu->isar.reset_pmcr_el0 =3D 0x410b3000; + acc->isar.reset_pmcr_el0 =3D 0x410b3000; } =20 -static void aarch64_a72_class_init(ARMCPUClass *cpu) +static void aarch64_a72_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "arm,cortex-a72"; - set_class_feature(cpu, ARM_FEATURE_V8); - set_class_feature(cpu, ARM_FEATURE_NEON); - set_class_feature(cpu, ARM_FEATURE_GENERIC_TIMER); - set_class_feature(cpu, ARM_FEATURE_AARCH64); - set_class_feature(cpu, ARM_FEATURE_CBAR_RO); - set_class_feature(cpu, ARM_FEATURE_EL2); - set_class_feature(cpu, ARM_FEATURE_EL3); - set_class_feature(cpu, ARM_FEATURE_PMU); - cpu->midr =3D 0x410fd083; - cpu->revidr =3D 0x00000000; - cpu->reset_fpsid =3D 0x41034080; - cpu->isar.mvfr0 =3D 0x10110222; - cpu->isar.mvfr1 =3D 0x12111111; - cpu->isar.mvfr2 =3D 0x00000043; - cpu->ctr =3D 0x8444c004; - cpu->reset_sctlr =3D 0x00c50838; - cpu->isar.id_pfr0 =3D 0x00000131; - cpu->isar.id_pfr1 =3D 0x00011011; - cpu->isar.id_dfr0 =3D 0x03010066; - cpu->id_afr0 =3D 0x00000000; - cpu->isar.id_mmfr0 =3D 0x10201105; - cpu->isar.id_mmfr1 =3D 0x40000000; - cpu->isar.id_mmfr2 =3D 0x01260000; - cpu->isar.id_mmfr3 =3D 0x02102211; - cpu->isar.id_isar0 =3D 0x02101110; - cpu->isar.id_isar1 =3D 0x13112111; - cpu->isar.id_isar2 =3D 0x21232042; - cpu->isar.id_isar3 =3D 0x01112131; - cpu->isar.id_isar4 =3D 0x00011142; - cpu->isar.id_isar5 =3D 0x00011121; - cpu->isar.id_aa64pfr0 =3D 0x00002222; - cpu->isar.id_aa64dfr0 =3D 0x10305106; - cpu->isar.id_aa64isar0 =3D 0x00011120; - cpu->isar.id_aa64mmfr0 =3D 0x00001124; - cpu->isar.dbgdidr =3D 0x3516d000; - cpu->isar.dbgdevid =3D 0x01110f13; - cpu->isar.dbgdevid1 =3D 0x2; - cpu->isar.reset_pmcr_el0 =3D 0x41023000; - cpu->clidr =3D 0x0a200023; - cpu->ccsidr[0] =3D 0x701fe00a; /* 32KB L1 dcache */ - cpu->ccsidr[1] =3D 0x201fe012; /* 48KB L1 icache */ - cpu->ccsidr[2] =3D 0x707fe07a; /* 1MB L2 cache */ - cpu->dcz_blocksize =3D 4; /* 64 bytes */ - cpu->gic_num_lrs =3D 4; - cpu->gic_vpribits =3D 5; - cpu->gic_vprebits =3D 5; - cpu->gic_pribits =3D 5; - define_cortex_a72_a57_a53_cp_reginfo(cpu); + acc->dtb_compatible =3D "arm,cortex-a72"; + set_class_feature(acc, ARM_FEATURE_V8); + set_class_feature(acc, ARM_FEATURE_NEON); + set_class_feature(acc, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(acc, ARM_FEATURE_AARCH64); + set_class_feature(acc, ARM_FEATURE_CBAR_RO); + set_class_feature(acc, ARM_FEATURE_EL2); + set_class_feature(acc, ARM_FEATURE_EL3); + set_class_feature(acc, ARM_FEATURE_PMU); + acc->midr =3D 0x410fd083; + acc->revidr =3D 0x00000000; + acc->reset_fpsid =3D 0x41034080; + acc->isar.mvfr0 =3D 0x10110222; + acc->isar.mvfr1 =3D 0x12111111; + acc->isar.mvfr2 =3D 0x00000043; + acc->ctr =3D 0x8444c004; + acc->reset_sctlr =3D 0x00c50838; + acc->isar.id_pfr0 =3D 0x00000131; + acc->isar.id_pfr1 =3D 0x00011011; + acc->isar.id_dfr0 =3D 0x03010066; + acc->id_afr0 =3D 0x00000000; + acc->isar.id_mmfr0 =3D 0x10201105; + acc->isar.id_mmfr1 =3D 0x40000000; + acc->isar.id_mmfr2 =3D 0x01260000; + acc->isar.id_mmfr3 =3D 0x02102211; + acc->isar.id_isar0 =3D 0x02101110; + acc->isar.id_isar1 =3D 0x13112111; + acc->isar.id_isar2 =3D 0x21232042; + acc->isar.id_isar3 =3D 0x01112131; + acc->isar.id_isar4 =3D 0x00011142; + acc->isar.id_isar5 =3D 0x00011121; + acc->isar.id_aa64pfr0 =3D 0x00002222; + acc->isar.id_aa64dfr0 =3D 0x10305106; + acc->isar.id_aa64isar0 =3D 0x00011120; + acc->isar.id_aa64mmfr0 =3D 0x00001124; + acc->isar.dbgdidr =3D 0x3516d000; + acc->isar.dbgdevid =3D 0x01110f13; + acc->isar.dbgdevid1 =3D 0x2; + acc->isar.reset_pmcr_el0 =3D 0x41023000; + acc->clidr =3D 0x0a200023; + acc->ccsidr[0] =3D 0x701fe00a; /* 32KB L1 dcache */ + acc->ccsidr[1] =3D 0x201fe012; /* 48KB L1 icache */ + acc->ccsidr[2] =3D 0x707fe07a; /* 1MB L2 cache */ + acc->dcz_blocksize =3D 4; /* 64 bytes */ + acc->gic_num_lrs =3D 4; + acc->gic_vpribits =3D 5; + acc->gic_vprebits =3D 5; + acc->gic_pribits =3D 5; + define_cortex_a72_a57_a53_cp_reginfo(acc); } =20 -static void aarch64_a76_class_init(ARMCPUClass *cpu) +static void aarch64_a76_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "arm,cortex-a76"; - set_class_feature(cpu, ARM_FEATURE_V8); - set_class_feature(cpu, ARM_FEATURE_NEON); - set_class_feature(cpu, ARM_FEATURE_GENERIC_TIMER); - set_class_feature(cpu, ARM_FEATURE_AARCH64); - set_class_feature(cpu, ARM_FEATURE_CBAR_RO); - set_class_feature(cpu, ARM_FEATURE_EL2); - set_class_feature(cpu, ARM_FEATURE_EL3); - set_class_feature(cpu, ARM_FEATURE_PMU); + acc->dtb_compatible =3D "arm,cortex-a76"; + set_class_feature(acc, ARM_FEATURE_V8); + set_class_feature(acc, ARM_FEATURE_NEON); + set_class_feature(acc, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(acc, ARM_FEATURE_AARCH64); + set_class_feature(acc, ARM_FEATURE_CBAR_RO); + set_class_feature(acc, ARM_FEATURE_EL2); + set_class_feature(acc, ARM_FEATURE_EL3); + set_class_feature(acc, ARM_FEATURE_PMU); =20 /* Ordered by B2.4 AArch64 registers by functional group */ - cpu->clidr =3D 0x82000023; - cpu->ctr =3D 0x8444C004; - cpu->dcz_blocksize =3D 4; - cpu->isar.id_aa64dfr0 =3D 0x0000000010305408ull; - cpu->isar.id_aa64isar0 =3D 0x0000100010211120ull; - cpu->isar.id_aa64isar1 =3D 0x0000000000100001ull; - cpu->isar.id_aa64mmfr0 =3D 0x0000000000101122ull; - cpu->isar.id_aa64mmfr1 =3D 0x0000000010212122ull; - cpu->isar.id_aa64mmfr2 =3D 0x0000000000001011ull; - cpu->isar.id_aa64pfr0 =3D 0x1100000010111112ull; /* GIC filled in lat= er */ - cpu->isar.id_aa64pfr1 =3D 0x0000000000000010ull; - cpu->id_afr0 =3D 0x00000000; - cpu->isar.id_dfr0 =3D 0x04010088; - cpu->isar.id_isar0 =3D 0x02101110; - cpu->isar.id_isar1 =3D 0x13112111; - cpu->isar.id_isar2 =3D 0x21232042; - cpu->isar.id_isar3 =3D 0x01112131; - cpu->isar.id_isar4 =3D 0x00010142; - cpu->isar.id_isar5 =3D 0x01011121; - cpu->isar.id_isar6 =3D 0x00000010; - cpu->isar.id_mmfr0 =3D 0x10201105; - cpu->isar.id_mmfr1 =3D 0x40000000; - cpu->isar.id_mmfr2 =3D 0x01260000; - cpu->isar.id_mmfr3 =3D 0x02122211; - cpu->isar.id_mmfr4 =3D 0x00021110; - cpu->isar.id_pfr0 =3D 0x10010131; - cpu->isar.id_pfr1 =3D 0x00010000; /* GIC filled in later */ - cpu->isar.id_pfr2 =3D 0x00000011; - cpu->midr =3D 0x414fd0b1; /* r4p1 */ - cpu->revidr =3D 0; + acc->clidr =3D 0x82000023; + acc->ctr =3D 0x8444C004; + acc->dcz_blocksize =3D 4; + acc->isar.id_aa64dfr0 =3D 0x0000000010305408ull; + acc->isar.id_aa64isar0 =3D 0x0000100010211120ull; + acc->isar.id_aa64isar1 =3D 0x0000000000100001ull; + acc->isar.id_aa64mmfr0 =3D 0x0000000000101122ull; + acc->isar.id_aa64mmfr1 =3D 0x0000000010212122ull; + acc->isar.id_aa64mmfr2 =3D 0x0000000000001011ull; + acc->isar.id_aa64pfr0 =3D 0x1100000010111112ull; /* GIC filled in lat= er */ + acc->isar.id_aa64pfr1 =3D 0x0000000000000010ull; + acc->id_afr0 =3D 0x00000000; + acc->isar.id_dfr0 =3D 0x04010088; + acc->isar.id_isar0 =3D 0x02101110; + acc->isar.id_isar1 =3D 0x13112111; + acc->isar.id_isar2 =3D 0x21232042; + acc->isar.id_isar3 =3D 0x01112131; + acc->isar.id_isar4 =3D 0x00010142; + acc->isar.id_isar5 =3D 0x01011121; + acc->isar.id_isar6 =3D 0x00000010; + acc->isar.id_mmfr0 =3D 0x10201105; + acc->isar.id_mmfr1 =3D 0x40000000; + acc->isar.id_mmfr2 =3D 0x01260000; + acc->isar.id_mmfr3 =3D 0x02122211; + acc->isar.id_mmfr4 =3D 0x00021110; + acc->isar.id_pfr0 =3D 0x10010131; + acc->isar.id_pfr1 =3D 0x00010000; /* GIC filled in later */ + acc->isar.id_pfr2 =3D 0x00000011; + acc->midr =3D 0x414fd0b1; /* r4p1 */ + acc->revidr =3D 0; =20 /* From B2.18 CCSIDR_EL1 */ - cpu->ccsidr[0] =3D 0x701fe01a; /* 64KB L1 dcache */ - cpu->ccsidr[1] =3D 0x201fe01a; /* 64KB L1 icache */ - cpu->ccsidr[2] =3D 0x707fe03a; /* 512KB L2 cache */ + acc->ccsidr[0] =3D 0x701fe01a; /* 64KB L1 dcache */ + acc->ccsidr[1] =3D 0x201fe01a; /* 64KB L1 icache */ + acc->ccsidr[2] =3D 0x707fe03a; /* 512KB L2 cache */ =20 /* From B2.93 SCTLR_EL3 */ - cpu->reset_sctlr =3D 0x30c50838; + acc->reset_sctlr =3D 0x30c50838; =20 /* From B4.23 ICH_VTR_EL2 */ - cpu->gic_num_lrs =3D 4; - cpu->gic_vpribits =3D 5; - cpu->gic_vprebits =3D 5; - cpu->gic_pribits =3D 5; + acc->gic_num_lrs =3D 4; + acc->gic_vpribits =3D 5; + acc->gic_vprebits =3D 5; + acc->gic_pribits =3D 5; =20 /* From B5.1 AdvSIMD AArch64 register summary */ - cpu->isar.mvfr0 =3D 0x10110222; - cpu->isar.mvfr1 =3D 0x13211111; - cpu->isar.mvfr2 =3D 0x00000043; + acc->isar.mvfr0 =3D 0x10110222; + acc->isar.mvfr1 =3D 0x13211111; + acc->isar.mvfr2 =3D 0x00000043; =20 /* From D5.1 AArch64 PMU register summary */ - cpu->isar.reset_pmcr_el0 =3D 0x410b3000; + acc->isar.reset_pmcr_el0 =3D 0x410b3000; } =20 -static void aarch64_a64fx_class_init(ARMCPUClass *cpu) +static void aarch64_a64fx_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "arm,a64fx"; - set_class_feature(cpu, ARM_FEATURE_V8); - set_class_feature(cpu, ARM_FEATURE_NEON); - set_class_feature(cpu, ARM_FEATURE_GENERIC_TIMER); - set_class_feature(cpu, ARM_FEATURE_AARCH64); - set_class_feature(cpu, ARM_FEATURE_EL2); - set_class_feature(cpu, ARM_FEATURE_EL3); - set_class_feature(cpu, ARM_FEATURE_PMU); - cpu->midr =3D 0x461f0010; - cpu->revidr =3D 0x00000000; - cpu->ctr =3D 0x86668006; - cpu->reset_sctlr =3D 0x30000180; - cpu->isar.id_aa64pfr0 =3D 0x0000000101111111; /* No RAS Extensions */ - cpu->isar.id_aa64pfr1 =3D 0x0000000000000000; - cpu->isar.id_aa64dfr0 =3D 0x0000000010305408; - cpu->isar.id_aa64dfr1 =3D 0x0000000000000000; - cpu->id_aa64afr0 =3D 0x0000000000000000; - cpu->id_aa64afr1 =3D 0x0000000000000000; - cpu->isar.id_aa64mmfr0 =3D 0x0000000000001122; - cpu->isar.id_aa64mmfr1 =3D 0x0000000011212100; - cpu->isar.id_aa64mmfr2 =3D 0x0000000000001011; - cpu->isar.id_aa64isar0 =3D 0x0000000010211120; - cpu->isar.id_aa64isar1 =3D 0x0000000000010001; - cpu->isar.id_aa64zfr0 =3D 0x0000000000000000; - cpu->clidr =3D 0x0000000080000023; - cpu->ccsidr[0] =3D 0x7007e01c; /* 64KB L1 dcache */ - cpu->ccsidr[1] =3D 0x2007e01c; /* 64KB L1 icache */ - cpu->ccsidr[2] =3D 0x70ffe07c; /* 8MB L2 cache */ - cpu->dcz_blocksize =3D 6; /* 256 bytes */ - cpu->gic_num_lrs =3D 4; - cpu->gic_vpribits =3D 5; - cpu->gic_vprebits =3D 5; - cpu->gic_pribits =3D 5; - cpu->isar.reset_pmcr_el0 =3D 0x46014040; + acc->dtb_compatible =3D "arm,a64fx"; + set_class_feature(acc, ARM_FEATURE_V8); + set_class_feature(acc, ARM_FEATURE_NEON); + set_class_feature(acc, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(acc, ARM_FEATURE_AARCH64); + set_class_feature(acc, ARM_FEATURE_EL2); + set_class_feature(acc, ARM_FEATURE_EL3); + set_class_feature(acc, ARM_FEATURE_PMU); + acc->midr =3D 0x461f0010; + acc->revidr =3D 0x00000000; + acc->ctr =3D 0x86668006; + acc->reset_sctlr =3D 0x30000180; + acc->isar.id_aa64pfr0 =3D 0x0000000101111111; /* No RAS Extensions */ + acc->isar.id_aa64pfr1 =3D 0x0000000000000000; + acc->isar.id_aa64dfr0 =3D 0x0000000010305408; + acc->isar.id_aa64dfr1 =3D 0x0000000000000000; + acc->id_aa64afr0 =3D 0x0000000000000000; + acc->id_aa64afr1 =3D 0x0000000000000000; + acc->isar.id_aa64mmfr0 =3D 0x0000000000001122; + acc->isar.id_aa64mmfr1 =3D 0x0000000011212100; + acc->isar.id_aa64mmfr2 =3D 0x0000000000001011; + acc->isar.id_aa64isar0 =3D 0x0000000010211120; + acc->isar.id_aa64isar1 =3D 0x0000000000010001; + acc->isar.id_aa64zfr0 =3D 0x0000000000000000; + acc->clidr =3D 0x0000000080000023; + acc->ccsidr[0] =3D 0x7007e01c; /* 64KB L1 dcache */ + acc->ccsidr[1] =3D 0x2007e01c; /* 64KB L1 icache */ + acc->ccsidr[2] =3D 0x70ffe07c; /* 8MB L2 cache */ + acc->dcz_blocksize =3D 6; /* 256 bytes */ + acc->gic_num_lrs =3D 4; + acc->gic_vpribits =3D 5; + acc->gic_vprebits =3D 5; + acc->gic_pribits =3D 5; + acc->isar.reset_pmcr_el0 =3D 0x46014040; =20 /* TODO: Add A64FX specific HPC extension registers */ } @@ -1023,71 +1023,71 @@ static void aarch64_a64fx_object_init(Object *obj) | (1 << 3); /* 512bit */ } =20 -static void aarch64_neoverse_n1_class_init(ARMCPUClass *cpu) +static void aarch64_neoverse_n1_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "arm,neoverse-n1"; - set_class_feature(cpu, ARM_FEATURE_V8); - set_class_feature(cpu, ARM_FEATURE_NEON); - set_class_feature(cpu, ARM_FEATURE_GENERIC_TIMER); - set_class_feature(cpu, ARM_FEATURE_AARCH64); - set_class_feature(cpu, ARM_FEATURE_CBAR_RO); - set_class_feature(cpu, ARM_FEATURE_EL2); - set_class_feature(cpu, ARM_FEATURE_EL3); - set_class_feature(cpu, ARM_FEATURE_PMU); + acc->dtb_compatible =3D "arm,neoverse-n1"; + set_class_feature(acc, ARM_FEATURE_V8); + set_class_feature(acc, ARM_FEATURE_NEON); + set_class_feature(acc, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(acc, ARM_FEATURE_AARCH64); + set_class_feature(acc, ARM_FEATURE_CBAR_RO); + set_class_feature(acc, ARM_FEATURE_EL2); + set_class_feature(acc, ARM_FEATURE_EL3); + set_class_feature(acc, ARM_FEATURE_PMU); =20 /* Ordered by B2.4 AArch64 registers by functional group */ - cpu->clidr =3D 0x82000023; - cpu->ctr =3D 0x8444c004; - cpu->dcz_blocksize =3D 4; - cpu->isar.id_aa64dfr0 =3D 0x0000000110305408ull; - cpu->isar.id_aa64isar0 =3D 0x0000100010211120ull; - cpu->isar.id_aa64isar1 =3D 0x0000000000100001ull; - cpu->isar.id_aa64mmfr0 =3D 0x0000000000101125ull; - cpu->isar.id_aa64mmfr1 =3D 0x0000000010212122ull; - cpu->isar.id_aa64mmfr2 =3D 0x0000000000001011ull; - cpu->isar.id_aa64pfr0 =3D 0x1100000010111112ull; /* GIC filled in lat= er */ - cpu->isar.id_aa64pfr1 =3D 0x0000000000000020ull; - cpu->id_afr0 =3D 0x00000000; - cpu->isar.id_dfr0 =3D 0x04010088; - cpu->isar.id_isar0 =3D 0x02101110; - cpu->isar.id_isar1 =3D 0x13112111; - cpu->isar.id_isar2 =3D 0x21232042; - cpu->isar.id_isar3 =3D 0x01112131; - cpu->isar.id_isar4 =3D 0x00010142; - cpu->isar.id_isar5 =3D 0x01011121; - cpu->isar.id_isar6 =3D 0x00000010; - cpu->isar.id_mmfr0 =3D 0x10201105; - cpu->isar.id_mmfr1 =3D 0x40000000; - cpu->isar.id_mmfr2 =3D 0x01260000; - cpu->isar.id_mmfr3 =3D 0x02122211; - cpu->isar.id_mmfr4 =3D 0x00021110; - cpu->isar.id_pfr0 =3D 0x10010131; - cpu->isar.id_pfr1 =3D 0x00010000; /* GIC filled in later */ - cpu->isar.id_pfr2 =3D 0x00000011; - cpu->midr =3D 0x414fd0c1; /* r4p1 */ - cpu->revidr =3D 0; + acc->clidr =3D 0x82000023; + acc->ctr =3D 0x8444c004; + acc->dcz_blocksize =3D 4; + acc->isar.id_aa64dfr0 =3D 0x0000000110305408ull; + acc->isar.id_aa64isar0 =3D 0x0000100010211120ull; + acc->isar.id_aa64isar1 =3D 0x0000000000100001ull; + acc->isar.id_aa64mmfr0 =3D 0x0000000000101125ull; + acc->isar.id_aa64mmfr1 =3D 0x0000000010212122ull; + acc->isar.id_aa64mmfr2 =3D 0x0000000000001011ull; + acc->isar.id_aa64pfr0 =3D 0x1100000010111112ull; /* GIC filled in lat= er */ + acc->isar.id_aa64pfr1 =3D 0x0000000000000020ull; + acc->id_afr0 =3D 0x00000000; + acc->isar.id_dfr0 =3D 0x04010088; + acc->isar.id_isar0 =3D 0x02101110; + acc->isar.id_isar1 =3D 0x13112111; + acc->isar.id_isar2 =3D 0x21232042; + acc->isar.id_isar3 =3D 0x01112131; + acc->isar.id_isar4 =3D 0x00010142; + acc->isar.id_isar5 =3D 0x01011121; + acc->isar.id_isar6 =3D 0x00000010; + acc->isar.id_mmfr0 =3D 0x10201105; + acc->isar.id_mmfr1 =3D 0x40000000; + acc->isar.id_mmfr2 =3D 0x01260000; + acc->isar.id_mmfr3 =3D 0x02122211; + acc->isar.id_mmfr4 =3D 0x00021110; + acc->isar.id_pfr0 =3D 0x10010131; + acc->isar.id_pfr1 =3D 0x00010000; /* GIC filled in later */ + acc->isar.id_pfr2 =3D 0x00000011; + acc->midr =3D 0x414fd0c1; /* r4p1 */ + acc->revidr =3D 0; =20 /* From B2.23 CCSIDR_EL1 */ - cpu->ccsidr[0] =3D 0x701fe01a; /* 64KB L1 dcache */ - cpu->ccsidr[1] =3D 0x201fe01a; /* 64KB L1 icache */ - cpu->ccsidr[2] =3D 0x70ffe03a; /* 1MB L2 cache */ + acc->ccsidr[0] =3D 0x701fe01a; /* 64KB L1 dcache */ + acc->ccsidr[1] =3D 0x201fe01a; /* 64KB L1 icache */ + acc->ccsidr[2] =3D 0x70ffe03a; /* 1MB L2 cache */ =20 /* From B2.98 SCTLR_EL3 */ - cpu->reset_sctlr =3D 0x30c50838; + acc->reset_sctlr =3D 0x30c50838; =20 /* From B4.23 ICH_VTR_EL2 */ - cpu->gic_num_lrs =3D 4; - cpu->gic_vpribits =3D 5; - cpu->gic_vprebits =3D 5; - cpu->gic_pribits =3D 5; + acc->gic_num_lrs =3D 4; + acc->gic_vpribits =3D 5; + acc->gic_vprebits =3D 5; + acc->gic_pribits =3D 5; =20 /* From B5.1 AdvSIMD AArch64 register summary */ - cpu->isar.mvfr0 =3D 0x10110222; - cpu->isar.mvfr1 =3D 0x13211111; - cpu->isar.mvfr2 =3D 0x00000043; + acc->isar.mvfr0 =3D 0x10110222; + acc->isar.mvfr1 =3D 0x13211111; + acc->isar.mvfr2 =3D 0x00000043; =20 /* From D5.1 AArch64 PMU register summary */ - cpu->isar.reset_pmcr_el0 =3D 0x410c3000; + acc->isar.reset_pmcr_el0 =3D 0x410c3000; } =20 static void aarch64_host_class_init(ARMCPUClass *acc) @@ -1136,22 +1136,22 @@ static void aarch64_host_object_init(Object *obj) * The version of '-cpu max' for qemu-system-arm is defined in cpu.c; * this version only needs to handle 64 bits. */ -static bool aarch64_max_class_late_init(ARMCPUClass *cpu, Error **errp) +static bool aarch64_max_class_late_init(ARMCPUClass *acc, Error **errp) { uint64_t t; uint32_t u; =20 if (kvm_enabled() || hvf_enabled()) { /* With KVM or HVF, '-cpu max' is identical to '-cpu host' */ - return aarch64_host_class_late_init(cpu, errp); + return aarch64_host_class_late_init(acc, errp); } =20 /* * '-cpu max' for TCG: we currently do this as "A57 with extra things" * Retain the more generic dtb_compatible setting from host_class_init. */ - aarch64_a57_class_init(cpu); - cpu->dtb_compatible =3D "arm,arm-v8"; + aarch64_a57_class_init(acc); + acc->dtb_compatible =3D "arm,arm-v8"; =20 /* * Reset MIDR so the guest doesn't mistake our 'max' CPU type for a re= al @@ -1170,18 +1170,18 @@ static bool aarch64_max_class_late_init(ARMCPUClass= *cpu, Error **errp) t =3D FIELD_DP64(t, MIDR_EL1, PARTNUM, 'Q'); t =3D FIELD_DP64(t, MIDR_EL1, VARIANT, 0); t =3D FIELD_DP64(t, MIDR_EL1, REVISION, 0); - cpu->midr =3D t; + acc->midr =3D t; =20 /* * We're going to set FEAT_S2FWB, which mandates that CLIDR_EL1.{LoUU,= LoUIS} * are zero. */ - u =3D cpu->clidr; + u =3D acc->clidr; u =3D FIELD_DP32(u, CLIDR_EL1, LOUIS, 0); u =3D FIELD_DP32(u, CLIDR_EL1, LOUU, 0); - cpu->clidr =3D u; + acc->clidr =3D u; =20 - t =3D cpu->isar.id_aa64isar0; + t =3D acc->isar.id_aa64isar0; t =3D FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* FEAT_PMULL */ t =3D FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); /* FEAT_SHA1 */ t =3D FIELD_DP64(t, ID_AA64ISAR0, SHA2, 2); /* FEAT_SHA512 */ @@ -1196,9 +1196,9 @@ static bool aarch64_max_class_late_init(ARMCPUClass *= cpu, Error **errp) t =3D FIELD_DP64(t, ID_AA64ISAR0, TS, 2); /* FEAT_FlagM2 */ t =3D FIELD_DP64(t, ID_AA64ISAR0, TLB, 2); /* FEAT_TLBIRANGE */ t =3D FIELD_DP64(t, ID_AA64ISAR0, RNDR, 1); /* FEAT_RNG */ - cpu->isar.id_aa64isar0 =3D t; + acc->isar.id_aa64isar0 =3D t; =20 - t =3D cpu->isar.id_aa64isar1; + t =3D acc->isar.id_aa64isar1; t =3D FIELD_DP64(t, ID_AA64ISAR1, DPB, 2); /* FEAT_DPB2 */ t =3D FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 1); /* FEAT_JSCVT */ t =3D FIELD_DP64(t, ID_AA64ISAR1, FCMA, 1); /* FEAT_FCMA */ @@ -1209,9 +1209,9 @@ static bool aarch64_max_class_late_init(ARMCPUClass *= cpu, Error **errp) t =3D FIELD_DP64(t, ID_AA64ISAR1, BF16, 1); /* FEAT_BF16 */ t =3D FIELD_DP64(t, ID_AA64ISAR1, DGH, 1); /* FEAT_DGH */ t =3D FIELD_DP64(t, ID_AA64ISAR1, I8MM, 1); /* FEAT_I8MM */ - cpu->isar.id_aa64isar1 =3D t; + acc->isar.id_aa64isar1 =3D t; =20 - t =3D cpu->isar.id_aa64pfr0; + t =3D acc->isar.id_aa64pfr0; t =3D FIELD_DP64(t, ID_AA64PFR0, FP, 1); /* FEAT_FP16 */ t =3D FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1); /* FEAT_FP16 */ t =3D FIELD_DP64(t, ID_AA64PFR0, RAS, 2); /* FEAT_RASv1p1 + FEAT= _DoubleFault */ @@ -1220,9 +1220,9 @@ static bool aarch64_max_class_late_init(ARMCPUClass *= cpu, Error **errp) t =3D FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */ t =3D FIELD_DP64(t, ID_AA64PFR0, CSV2, 2); /* FEAT_CSV2_2 */ t =3D FIELD_DP64(t, ID_AA64PFR0, CSV3, 1); /* FEAT_CSV3 */ - cpu->isar.id_aa64pfr0 =3D t; + acc->isar.id_aa64pfr0 =3D t; =20 - t =3D cpu->isar.id_aa64pfr1; + t =3D acc->isar.id_aa64pfr1; t =3D FIELD_DP64(t, ID_AA64PFR1, BT, 1); /* FEAT_BTI */ t =3D FIELD_DP64(t, ID_AA64PFR1, SSBS, 2); /* FEAT_SSBS2 */ /* @@ -1234,17 +1234,17 @@ static bool aarch64_max_class_late_init(ARMCPUClass= *cpu, Error **errp) t =3D FIELD_DP64(t, ID_AA64PFR1, RAS_FRAC, 0); /* FEAT_RASv1p1 + FEAT= _DoubleFault */ t =3D FIELD_DP64(t, ID_AA64PFR1, SME, 1); /* FEAT_SME */ t =3D FIELD_DP64(t, ID_AA64PFR1, CSV2_FRAC, 0); /* FEAT_CSV2_2 */ - cpu->isar.id_aa64pfr1 =3D t; + acc->isar.id_aa64pfr1 =3D t; =20 - t =3D cpu->isar.id_aa64mmfr0; + t =3D acc->isar.id_aa64mmfr0; t =3D FIELD_DP64(t, ID_AA64MMFR0, PARANGE, 6); /* FEAT_LPA: 52 bits */ t =3D FIELD_DP64(t, ID_AA64MMFR0, TGRAN16, 1); /* 16k pages supporte= d */ t =3D FIELD_DP64(t, ID_AA64MMFR0, TGRAN16_2, 2); /* 16k stage2 support= ed */ t =3D FIELD_DP64(t, ID_AA64MMFR0, TGRAN64_2, 2); /* 64k stage2 support= ed */ t =3D FIELD_DP64(t, ID_AA64MMFR0, TGRAN4_2, 2); /* 4k stage2 support= ed */ - cpu->isar.id_aa64mmfr0 =3D t; + acc->isar.id_aa64mmfr0 =3D t; =20 - t =3D cpu->isar.id_aa64mmfr1; + t =3D acc->isar.id_aa64mmfr1; t =3D FIELD_DP64(t, ID_AA64MMFR1, HAFDBS, 2); /* FEAT_HAFDBS */ t =3D FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* FEAT_VMID16 */ t =3D FIELD_DP64(t, ID_AA64MMFR1, VH, 1); /* FEAT_VHE */ @@ -1254,9 +1254,9 @@ static bool aarch64_max_class_late_init(ARMCPUClass *= cpu, Error **errp) t =3D FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* FEAT_XNX */ t =3D FIELD_DP64(t, ID_AA64MMFR1, ETS, 1); /* FEAT_ETS */ t =3D FIELD_DP64(t, ID_AA64MMFR1, HCX, 1); /* FEAT_HCX */ - cpu->isar.id_aa64mmfr1 =3D t; + acc->isar.id_aa64mmfr1 =3D t; =20 - t =3D cpu->isar.id_aa64mmfr2; + t =3D acc->isar.id_aa64mmfr2; t =3D FIELD_DP64(t, ID_AA64MMFR2, CNP, 1); /* FEAT_TTCNP */ t =3D FIELD_DP64(t, ID_AA64MMFR2, UAO, 1); /* FEAT_UAO */ t =3D FIELD_DP64(t, ID_AA64MMFR2, IESB, 1); /* FEAT_IESB */ @@ -1268,9 +1268,9 @@ static bool aarch64_max_class_late_init(ARMCPUClass *= cpu, Error **errp) t =3D FIELD_DP64(t, ID_AA64MMFR2, BBM, 2); /* FEAT_BBM at level 2= */ t =3D FIELD_DP64(t, ID_AA64MMFR2, EVT, 2); /* FEAT_EVT */ t =3D FIELD_DP64(t, ID_AA64MMFR2, E0PD, 1); /* FEAT_E0PD */ - cpu->isar.id_aa64mmfr2 =3D t; + acc->isar.id_aa64mmfr2 =3D t; =20 - t =3D cpu->isar.id_aa64zfr0; + t =3D acc->isar.id_aa64zfr0; t =3D FIELD_DP64(t, ID_AA64ZFR0, SVEVER, 1); t =3D FIELD_DP64(t, ID_AA64ZFR0, AES, 2); /* FEAT_SVE_PMULL128 */ t =3D FIELD_DP64(t, ID_AA64ZFR0, BITPERM, 1); /* FEAT_SVE_BitPerm */ @@ -1280,14 +1280,14 @@ static bool aarch64_max_class_late_init(ARMCPUClass= *cpu, Error **errp) t =3D FIELD_DP64(t, ID_AA64ZFR0, I8MM, 1); /* FEAT_I8MM */ t =3D FIELD_DP64(t, ID_AA64ZFR0, F32MM, 1); /* FEAT_F32MM */ t =3D FIELD_DP64(t, ID_AA64ZFR0, F64MM, 1); /* FEAT_F64MM */ - cpu->isar.id_aa64zfr0 =3D t; + acc->isar.id_aa64zfr0 =3D t; =20 - t =3D cpu->isar.id_aa64dfr0; + t =3D acc->isar.id_aa64dfr0; t =3D FIELD_DP64(t, ID_AA64DFR0, DEBUGVER, 9); /* FEAT_Debugv8p4 */ t =3D FIELD_DP64(t, ID_AA64DFR0, PMUVER, 6); /* FEAT_PMUv3p5 */ - cpu->isar.id_aa64dfr0 =3D t; + acc->isar.id_aa64dfr0 =3D t; =20 - t =3D cpu->isar.id_aa64smfr0; + t =3D acc->isar.id_aa64smfr0; t =3D FIELD_DP64(t, ID_AA64SMFR0, F32F32, 1); /* FEAT_SME */ t =3D FIELD_DP64(t, ID_AA64SMFR0, B16F32, 1); /* FEAT_SME */ t =3D FIELD_DP64(t, ID_AA64SMFR0, F16F32, 1); /* FEAT_SME */ @@ -1295,18 +1295,18 @@ static bool aarch64_max_class_late_init(ARMCPUClass= *cpu, Error **errp) t =3D FIELD_DP64(t, ID_AA64SMFR0, F64F64, 1); /* FEAT_SME_F64F64 */ t =3D FIELD_DP64(t, ID_AA64SMFR0, I16I64, 0xf); /* FEAT_SME_I16I64 */ t =3D FIELD_DP64(t, ID_AA64SMFR0, FA64, 1); /* FEAT_SME_FA64 */ - cpu->isar.id_aa64smfr0 =3D t; + acc->isar.id_aa64smfr0 =3D t; =20 /* Replicate the same data to the 32-bit id registers. */ - aa32_max_features(cpu); + aa32_max_features(acc); =20 #ifdef CONFIG_USER_ONLY /* * For usermode -cpu max we can use a larger and more efficient DCZ * blocksize since we don't have to follow what the hardware does. */ - cpu->ctr =3D 0x80038003; /* 32 byte I and D cacheline size, VIPT icach= e */ - cpu->dcz_blocksize =3D 7; /* 512 bytes */ + acc->ctr =3D 0x80038003; /* 32 byte I and D cacheline size, VIPT icach= e */ + acc->dcz_blocksize =3D 7; /* 512 bytes */ #endif return true; } diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c index f35b4a52b0..1ef825b39e 100644 --- a/target/arm/cpu_tcg.c +++ b/target/arm/cpu_tcg.c @@ -22,21 +22,21 @@ =20 =20 /* Share AArch32 -cpu max features with AArch64. */ -void aa32_max_features(ARMCPUClass *cpu) +void aa32_max_features(ARMCPUClass *acc) { uint32_t t; =20 /* Add additional features supported by QEMU */ - t =3D cpu->isar.id_isar5; + t =3D acc->isar.id_isar5; t =3D FIELD_DP32(t, ID_ISAR5, AES, 2); /* FEAT_PMULL */ t =3D FIELD_DP32(t, ID_ISAR5, SHA1, 1); /* FEAT_SHA1 */ t =3D FIELD_DP32(t, ID_ISAR5, SHA2, 1); /* FEAT_SHA256 */ t =3D FIELD_DP32(t, ID_ISAR5, CRC32, 1); t =3D FIELD_DP32(t, ID_ISAR5, RDM, 1); /* FEAT_RDM */ t =3D FIELD_DP32(t, ID_ISAR5, VCMA, 1); /* FEAT_FCMA */ - cpu->isar.id_isar5 =3D t; + acc->isar.id_isar5 =3D t; =20 - t =3D cpu->isar.id_isar6; + t =3D acc->isar.id_isar6; t =3D FIELD_DP32(t, ID_ISAR6, JSCVT, 1); /* FEAT_JSCVT */ t =3D FIELD_DP32(t, ID_ISAR6, DP, 1); /* Feat_DotProd */ t =3D FIELD_DP32(t, ID_ISAR6, FHM, 1); /* FEAT_FHM */ @@ -44,50 +44,50 @@ void aa32_max_features(ARMCPUClass *cpu) t =3D FIELD_DP32(t, ID_ISAR6, SPECRES, 1); /* FEAT_SPECRES */ t =3D FIELD_DP32(t, ID_ISAR6, BF16, 1); /* FEAT_AA32BF16 */ t =3D FIELD_DP32(t, ID_ISAR6, I8MM, 1); /* FEAT_AA32I8MM */ - cpu->isar.id_isar6 =3D t; + acc->isar.id_isar6 =3D t; =20 - t =3D cpu->isar.mvfr1; + t =3D acc->isar.mvfr1; t =3D FIELD_DP32(t, MVFR1, FPHP, 3); /* FEAT_FP16 */ t =3D FIELD_DP32(t, MVFR1, SIMDHP, 2); /* FEAT_FP16 */ - cpu->isar.mvfr1 =3D t; + acc->isar.mvfr1 =3D t; =20 - t =3D cpu->isar.mvfr2; + t =3D acc->isar.mvfr2; t =3D FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */ t =3D FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ - cpu->isar.mvfr2 =3D t; + acc->isar.mvfr2 =3D t; =20 - t =3D cpu->isar.id_mmfr3; + t =3D acc->isar.id_mmfr3; t =3D FIELD_DP32(t, ID_MMFR3, PAN, 2); /* FEAT_PAN2 */ - cpu->isar.id_mmfr3 =3D t; + acc->isar.id_mmfr3 =3D t; =20 - t =3D cpu->isar.id_mmfr4; + t =3D acc->isar.id_mmfr4; t =3D FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* FEAT_AA32HPD */ t =3D FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ t =3D FIELD_DP32(t, ID_MMFR4, CNP, 1); /* FEAT_TTCNP */ t =3D FIELD_DP32(t, ID_MMFR4, XNX, 1); /* FEAT_XNX */ t =3D FIELD_DP32(t, ID_MMFR4, EVT, 2); /* FEAT_EVT */ - cpu->isar.id_mmfr4 =3D t; + acc->isar.id_mmfr4 =3D t; =20 - t =3D cpu->isar.id_mmfr5; + t =3D acc->isar.id_mmfr5; t =3D FIELD_DP32(t, ID_MMFR5, ETS, 1); /* FEAT_ETS */ - cpu->isar.id_mmfr5 =3D t; + acc->isar.id_mmfr5 =3D t; =20 - t =3D cpu->isar.id_pfr0; + t =3D acc->isar.id_pfr0; t =3D FIELD_DP32(t, ID_PFR0, CSV2, 2); /* FEAT_CVS2 */ t =3D FIELD_DP32(t, ID_PFR0, DIT, 1); /* FEAT_DIT */ t =3D FIELD_DP32(t, ID_PFR0, RAS, 1); /* FEAT_RAS */ - cpu->isar.id_pfr0 =3D t; + acc->isar.id_pfr0 =3D t; =20 - t =3D cpu->isar.id_pfr2; + t =3D acc->isar.id_pfr2; t =3D FIELD_DP32(t, ID_PFR2, CSV3, 1); /* FEAT_CSV3 */ t =3D FIELD_DP32(t, ID_PFR2, SSBS, 1); /* FEAT_SSBS */ - cpu->isar.id_pfr2 =3D t; + acc->isar.id_pfr2 =3D t; =20 - t =3D cpu->isar.id_dfr0; + t =3D acc->isar.id_dfr0; t =3D FIELD_DP32(t, ID_DFR0, COPDBG, 9); /* FEAT_Debugv8p4 */ t =3D FIELD_DP32(t, ID_DFR0, COPSDBG, 9); /* FEAT_Debugv8p4 */ t =3D FIELD_DP32(t, ID_DFR0, PERFMON, 6); /* FEAT_PMUv3p5 */ - cpu->isar.id_dfr0 =3D t; + acc->isar.id_dfr0 =3D t; } =20 #ifndef CONFIG_USER_ONLY @@ -178,43 +178,43 @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, = int interrupt_request) } #endif /* !CONFIG_USER_ONLY && CONFIG_TCG */ =20 -static void arm926_class_init(ARMCPUClass *cpu) +static void arm926_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "arm,arm926"; - set_class_feature(cpu, ARM_FEATURE_V5); - set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); - set_class_feature(cpu, ARM_FEATURE_CACHE_TEST_CLEAN); - cpu->midr =3D 0x41069265; - cpu->reset_fpsid =3D 0x41011090; - cpu->ctr =3D 0x1dd20d2; - cpu->reset_sctlr =3D 0x00090078; + acc->dtb_compatible =3D "arm,arm926"; + set_class_feature(acc, ARM_FEATURE_V5); + set_class_feature(acc, ARM_FEATURE_DUMMY_C15_REGS); + set_class_feature(acc, ARM_FEATURE_CACHE_TEST_CLEAN); + acc->midr =3D 0x41069265; + acc->reset_fpsid =3D 0x41011090; + acc->ctr =3D 0x1dd20d2; + acc->reset_sctlr =3D 0x00090078; =20 /* * ARMv5 does not have the ID_ISAR registers, but we can still * set the field to indicate Jazelle support within QEMU. */ - cpu->isar.id_isar1 =3D FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELL= E, 1); + acc->isar.id_isar1 =3D FIELD_DP32(acc->isar.id_isar1, ID_ISAR1, JAZELL= E, 1); /* * Similarly, we need to set MVFR0 fields to enable vfp and short vect= or * support even though ARMv5 doesn't have this register. */ - cpu->isar.mvfr0 =3D FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); - cpu->isar.mvfr0 =3D FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSP, 1); - cpu->isar.mvfr0 =3D FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1); + acc->isar.mvfr0 =3D FIELD_DP32(acc->isar.mvfr0, MVFR0, FPSHVEC, 1); + acc->isar.mvfr0 =3D FIELD_DP32(acc->isar.mvfr0, MVFR0, FPSP, 1); + acc->isar.mvfr0 =3D FIELD_DP32(acc->isar.mvfr0, MVFR0, FPDP, 1); } =20 -static void arm946_class_init(ARMCPUClass *cpu) +static void arm946_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "arm,arm946"; - set_class_feature(cpu, ARM_FEATURE_V5); - set_class_feature(cpu, ARM_FEATURE_PMSA); - set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); - cpu->midr =3D 0x41059461; - cpu->ctr =3D 0x0f004006; - cpu->reset_sctlr =3D 0x00000078; + acc->dtb_compatible =3D "arm,arm946"; + set_class_feature(acc, ARM_FEATURE_V5); + set_class_feature(acc, ARM_FEATURE_PMSA); + set_class_feature(acc, ARM_FEATURE_DUMMY_C15_REGS); + acc->midr =3D 0x41059461; + acc->ctr =3D 0x0f004006; + acc->reset_sctlr =3D 0x00000078; } =20 -static void arm1026_class_init(ARMCPUClass *cpu) +static void arm1026_class_init(ARMCPUClass *acc) { /* The 1026 had an IFAR at c6,c0,0,1 rather than the ARMv6 c6,c0,0,2 */ static const ARMCPRegInfo ifar[1] =3D { @@ -224,34 +224,34 @@ static void arm1026_class_init(ARMCPUClass *cpu) .resetvalue =3D 0 } }; =20 - cpu->dtb_compatible =3D "arm,arm1026"; - set_class_feature(cpu, ARM_FEATURE_V5); - set_class_feature(cpu, ARM_FEATURE_AUXCR); - set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); - set_class_feature(cpu, ARM_FEATURE_CACHE_TEST_CLEAN); - cpu->midr =3D 0x4106a262; - cpu->reset_fpsid =3D 0x410110a0; - cpu->ctr =3D 0x1dd20d2; - cpu->reset_sctlr =3D 0x00090078; - cpu->reset_auxcr =3D 1; + acc->dtb_compatible =3D "arm,arm1026"; + set_class_feature(acc, ARM_FEATURE_V5); + set_class_feature(acc, ARM_FEATURE_AUXCR); + set_class_feature(acc, ARM_FEATURE_DUMMY_C15_REGS); + set_class_feature(acc, ARM_FEATURE_CACHE_TEST_CLEAN); + acc->midr =3D 0x4106a262; + acc->reset_fpsid =3D 0x410110a0; + acc->ctr =3D 0x1dd20d2; + acc->reset_sctlr =3D 0x00090078; + acc->reset_auxcr =3D 1; =20 /* * ARMv5 does not have the ID_ISAR registers, but we can still * set the field to indicate Jazelle support within QEMU. */ - cpu->isar.id_isar1 =3D FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELL= E, 1); + acc->isar.id_isar1 =3D FIELD_DP32(acc->isar.id_isar1, ID_ISAR1, JAZELL= E, 1); /* * Similarly, we need to set MVFR0 fields to enable vfp and short vect= or * support even though ARMv5 doesn't have this register. */ - cpu->isar.mvfr0 =3D FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); - cpu->isar.mvfr0 =3D FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSP, 1); - cpu->isar.mvfr0 =3D FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1); + acc->isar.mvfr0 =3D FIELD_DP32(acc->isar.mvfr0, MVFR0, FPSHVEC, 1); + acc->isar.mvfr0 =3D FIELD_DP32(acc->isar.mvfr0, MVFR0, FPSP, 1); + acc->isar.mvfr0 =3D FIELD_DP32(acc->isar.mvfr0, MVFR0, FPDP, 1); =20 - define_arm_cp_regs_with_class(cpu, ifar, NULL); + define_arm_cp_regs_with_class(acc, ifar, NULL); } =20 -static void arm1136_r2_class_init(ARMCPUClass *cpu) +static void arm1136_r2_class_init(ARMCPUClass *acc) { /* * What qemu calls "arm1136_r2" is actually the 1136 r0p2, ie an @@ -262,116 +262,116 @@ static void arm1136_r2_class_init(ARMCPUClass *cpu) * of the ID registers). */ =20 - cpu->dtb_compatible =3D "arm,arm1136"; - set_class_feature(cpu, ARM_FEATURE_V6); - set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); - set_class_feature(cpu, ARM_FEATURE_CACHE_DIRTY_REG); - set_class_feature(cpu, ARM_FEATURE_CACHE_BLOCK_OPS); - cpu->midr =3D 0x4107b362; - cpu->reset_fpsid =3D 0x410120b4; - cpu->isar.mvfr0 =3D 0x11111111; - cpu->isar.mvfr1 =3D 0x00000000; - cpu->ctr =3D 0x1dd20d2; - cpu->reset_sctlr =3D 0x00050078; - cpu->isar.id_pfr0 =3D 0x111; - cpu->isar.id_pfr1 =3D 0x1; - cpu->isar.id_dfr0 =3D 0x2; - cpu->id_afr0 =3D 0x3; - cpu->isar.id_mmfr0 =3D 0x01130003; - cpu->isar.id_mmfr1 =3D 0x10030302; - cpu->isar.id_mmfr2 =3D 0x01222110; - cpu->isar.id_isar0 =3D 0x00140011; - cpu->isar.id_isar1 =3D 0x12002111; - cpu->isar.id_isar2 =3D 0x11231111; - cpu->isar.id_isar3 =3D 0x01102131; - cpu->isar.id_isar4 =3D 0x141; - cpu->reset_auxcr =3D 7; + acc->dtb_compatible =3D "arm,arm1136"; + set_class_feature(acc, ARM_FEATURE_V6); + set_class_feature(acc, ARM_FEATURE_DUMMY_C15_REGS); + set_class_feature(acc, ARM_FEATURE_CACHE_DIRTY_REG); + set_class_feature(acc, ARM_FEATURE_CACHE_BLOCK_OPS); + acc->midr =3D 0x4107b362; + acc->reset_fpsid =3D 0x410120b4; + acc->isar.mvfr0 =3D 0x11111111; + acc->isar.mvfr1 =3D 0x00000000; + acc->ctr =3D 0x1dd20d2; + acc->reset_sctlr =3D 0x00050078; + acc->isar.id_pfr0 =3D 0x111; + acc->isar.id_pfr1 =3D 0x1; + acc->isar.id_dfr0 =3D 0x2; + acc->id_afr0 =3D 0x3; + acc->isar.id_mmfr0 =3D 0x01130003; + acc->isar.id_mmfr1 =3D 0x10030302; + acc->isar.id_mmfr2 =3D 0x01222110; + acc->isar.id_isar0 =3D 0x00140011; + acc->isar.id_isar1 =3D 0x12002111; + acc->isar.id_isar2 =3D 0x11231111; + acc->isar.id_isar3 =3D 0x01102131; + acc->isar.id_isar4 =3D 0x141; + acc->reset_auxcr =3D 7; } =20 -static void arm1136_class_init(ARMCPUClass *cpu) +static void arm1136_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "arm,arm1136"; - set_class_feature(cpu, ARM_FEATURE_V6K); - set_class_feature(cpu, ARM_FEATURE_V6); - set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); - set_class_feature(cpu, ARM_FEATURE_CACHE_DIRTY_REG); - set_class_feature(cpu, ARM_FEATURE_CACHE_BLOCK_OPS); - cpu->midr =3D 0x4117b363; - cpu->reset_fpsid =3D 0x410120b4; - cpu->isar.mvfr0 =3D 0x11111111; - cpu->isar.mvfr1 =3D 0x00000000; - cpu->ctr =3D 0x1dd20d2; - cpu->reset_sctlr =3D 0x00050078; - cpu->isar.id_pfr0 =3D 0x111; - cpu->isar.id_pfr1 =3D 0x1; - cpu->isar.id_dfr0 =3D 0x2; - cpu->id_afr0 =3D 0x3; - cpu->isar.id_mmfr0 =3D 0x01130003; - cpu->isar.id_mmfr1 =3D 0x10030302; - cpu->isar.id_mmfr2 =3D 0x01222110; - cpu->isar.id_isar0 =3D 0x00140011; - cpu->isar.id_isar1 =3D 0x12002111; - cpu->isar.id_isar2 =3D 0x11231111; - cpu->isar.id_isar3 =3D 0x01102131; - cpu->isar.id_isar4 =3D 0x141; - cpu->reset_auxcr =3D 7; + acc->dtb_compatible =3D "arm,arm1136"; + set_class_feature(acc, ARM_FEATURE_V6K); + set_class_feature(acc, ARM_FEATURE_V6); + set_class_feature(acc, ARM_FEATURE_DUMMY_C15_REGS); + set_class_feature(acc, ARM_FEATURE_CACHE_DIRTY_REG); + set_class_feature(acc, ARM_FEATURE_CACHE_BLOCK_OPS); + acc->midr =3D 0x4117b363; + acc->reset_fpsid =3D 0x410120b4; + acc->isar.mvfr0 =3D 0x11111111; + acc->isar.mvfr1 =3D 0x00000000; + acc->ctr =3D 0x1dd20d2; + acc->reset_sctlr =3D 0x00050078; + acc->isar.id_pfr0 =3D 0x111; + acc->isar.id_pfr1 =3D 0x1; + acc->isar.id_dfr0 =3D 0x2; + acc->id_afr0 =3D 0x3; + acc->isar.id_mmfr0 =3D 0x01130003; + acc->isar.id_mmfr1 =3D 0x10030302; + acc->isar.id_mmfr2 =3D 0x01222110; + acc->isar.id_isar0 =3D 0x00140011; + acc->isar.id_isar1 =3D 0x12002111; + acc->isar.id_isar2 =3D 0x11231111; + acc->isar.id_isar3 =3D 0x01102131; + acc->isar.id_isar4 =3D 0x141; + acc->reset_auxcr =3D 7; } =20 -static void arm1176_class_init(ARMCPUClass *cpu) +static void arm1176_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "arm,arm1176"; - set_class_feature(cpu, ARM_FEATURE_V6K); - set_class_feature(cpu, ARM_FEATURE_VAPA); - set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); - set_class_feature(cpu, ARM_FEATURE_CACHE_DIRTY_REG); - set_class_feature(cpu, ARM_FEATURE_CACHE_BLOCK_OPS); - set_class_feature(cpu, ARM_FEATURE_EL3); - cpu->midr =3D 0x410fb767; - cpu->reset_fpsid =3D 0x410120b5; - cpu->isar.mvfr0 =3D 0x11111111; - cpu->isar.mvfr1 =3D 0x00000000; - cpu->ctr =3D 0x1dd20d2; - cpu->reset_sctlr =3D 0x00050078; - cpu->isar.id_pfr0 =3D 0x111; - cpu->isar.id_pfr1 =3D 0x11; - cpu->isar.id_dfr0 =3D 0x33; - cpu->id_afr0 =3D 0; - cpu->isar.id_mmfr0 =3D 0x01130003; - cpu->isar.id_mmfr1 =3D 0x10030302; - cpu->isar.id_mmfr2 =3D 0x01222100; - cpu->isar.id_isar0 =3D 0x0140011; - cpu->isar.id_isar1 =3D 0x12002111; - cpu->isar.id_isar2 =3D 0x11231121; - cpu->isar.id_isar3 =3D 0x01102131; - cpu->isar.id_isar4 =3D 0x01141; - cpu->reset_auxcr =3D 7; + acc->dtb_compatible =3D "arm,arm1176"; + set_class_feature(acc, ARM_FEATURE_V6K); + set_class_feature(acc, ARM_FEATURE_VAPA); + set_class_feature(acc, ARM_FEATURE_DUMMY_C15_REGS); + set_class_feature(acc, ARM_FEATURE_CACHE_DIRTY_REG); + set_class_feature(acc, ARM_FEATURE_CACHE_BLOCK_OPS); + set_class_feature(acc, ARM_FEATURE_EL3); + acc->midr =3D 0x410fb767; + acc->reset_fpsid =3D 0x410120b5; + acc->isar.mvfr0 =3D 0x11111111; + acc->isar.mvfr1 =3D 0x00000000; + acc->ctr =3D 0x1dd20d2; + acc->reset_sctlr =3D 0x00050078; + acc->isar.id_pfr0 =3D 0x111; + acc->isar.id_pfr1 =3D 0x11; + acc->isar.id_dfr0 =3D 0x33; + acc->id_afr0 =3D 0; + acc->isar.id_mmfr0 =3D 0x01130003; + acc->isar.id_mmfr1 =3D 0x10030302; + acc->isar.id_mmfr2 =3D 0x01222100; + acc->isar.id_isar0 =3D 0x0140011; + acc->isar.id_isar1 =3D 0x12002111; + acc->isar.id_isar2 =3D 0x11231121; + acc->isar.id_isar3 =3D 0x01102131; + acc->isar.id_isar4 =3D 0x01141; + acc->reset_auxcr =3D 7; } =20 -static void arm11mpcore_class_init(ARMCPUClass *cpu) +static void arm11mpcore_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "arm,arm11mpcore"; - set_class_feature(cpu, ARM_FEATURE_V6K); - set_class_feature(cpu, ARM_FEATURE_VAPA); - set_class_feature(cpu, ARM_FEATURE_MPIDR); - set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); - cpu->midr =3D 0x410fb022; - cpu->reset_fpsid =3D 0x410120b4; - cpu->isar.mvfr0 =3D 0x11111111; - cpu->isar.mvfr1 =3D 0x00000000; - cpu->ctr =3D 0x1d192992; /* 32K icache 32K dcache */ - cpu->isar.id_pfr0 =3D 0x111; - cpu->isar.id_pfr1 =3D 0x1; - cpu->isar.id_dfr0 =3D 0; - cpu->id_afr0 =3D 0x2; - cpu->isar.id_mmfr0 =3D 0x01100103; - cpu->isar.id_mmfr1 =3D 0x10020302; - cpu->isar.id_mmfr2 =3D 0x01222000; - cpu->isar.id_isar0 =3D 0x00100011; - cpu->isar.id_isar1 =3D 0x12002111; - cpu->isar.id_isar2 =3D 0x11221011; - cpu->isar.id_isar3 =3D 0x01102131; - cpu->isar.id_isar4 =3D 0x141; - cpu->reset_auxcr =3D 1; + acc->dtb_compatible =3D "arm,arm11mpcore"; + set_class_feature(acc, ARM_FEATURE_V6K); + set_class_feature(acc, ARM_FEATURE_VAPA); + set_class_feature(acc, ARM_FEATURE_MPIDR); + set_class_feature(acc, ARM_FEATURE_DUMMY_C15_REGS); + acc->midr =3D 0x410fb022; + acc->reset_fpsid =3D 0x410120b4; + acc->isar.mvfr0 =3D 0x11111111; + acc->isar.mvfr1 =3D 0x00000000; + acc->ctr =3D 0x1d192992; /* 32K icache 32K dcache */ + acc->isar.id_pfr0 =3D 0x111; + acc->isar.id_pfr1 =3D 0x1; + acc->isar.id_dfr0 =3D 0; + acc->id_afr0 =3D 0x2; + acc->isar.id_mmfr0 =3D 0x01100103; + acc->isar.id_mmfr1 =3D 0x10020302; + acc->isar.id_mmfr2 =3D 0x01222000; + acc->isar.id_isar0 =3D 0x00100011; + acc->isar.id_isar1 =3D 0x12002111; + acc->isar.id_isar2 =3D 0x11221011; + acc->isar.id_isar3 =3D 0x01102131; + acc->isar.id_isar4 =3D 0x141; + acc->reset_auxcr =3D 1; } =20 static const ARMCPRegInfo cortexa8_cp_reginfo[] =3D { @@ -381,41 +381,41 @@ static const ARMCPRegInfo cortexa8_cp_reginfo[] =3D { .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, }; =20 -static void cortex_a8_class_init(ARMCPUClass *cpu) +static void cortex_a8_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "arm,cortex-a8"; - set_class_feature(cpu, ARM_FEATURE_V7); - set_class_feature(cpu, ARM_FEATURE_NEON); - set_class_feature(cpu, ARM_FEATURE_THUMB2EE); - set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); - set_class_feature(cpu, ARM_FEATURE_EL3); - cpu->midr =3D 0x410fc080; - cpu->reset_fpsid =3D 0x410330c0; - cpu->isar.mvfr0 =3D 0x11110222; - cpu->isar.mvfr1 =3D 0x00011111; - cpu->ctr =3D 0x82048004; - cpu->reset_sctlr =3D 0x00c50078; - cpu->isar.id_pfr0 =3D 0x1031; - cpu->isar.id_pfr1 =3D 0x11; - cpu->isar.id_dfr0 =3D 0x400; - cpu->id_afr0 =3D 0; - cpu->isar.id_mmfr0 =3D 0x31100003; - cpu->isar.id_mmfr1 =3D 0x20000000; - cpu->isar.id_mmfr2 =3D 0x01202000; - cpu->isar.id_mmfr3 =3D 0x11; - cpu->isar.id_isar0 =3D 0x00101111; - cpu->isar.id_isar1 =3D 0x12112111; - cpu->isar.id_isar2 =3D 0x21232031; - cpu->isar.id_isar3 =3D 0x11112131; - cpu->isar.id_isar4 =3D 0x00111142; - cpu->isar.dbgdidr =3D 0x15141000; - cpu->clidr =3D (1 << 27) | (2 << 24) | 3; - cpu->ccsidr[0] =3D 0xe007e01a; /* 16k L1 dcache. */ - cpu->ccsidr[1] =3D 0x2007e01a; /* 16k L1 icache. */ - cpu->ccsidr[2] =3D 0xf0000000; /* No L2 icache. */ - cpu->reset_auxcr =3D 2; - cpu->isar.reset_pmcr_el0 =3D 0x41002000; - define_arm_cp_regs_with_class(cpu, cortexa8_cp_reginfo, NULL); + acc->dtb_compatible =3D "arm,cortex-a8"; + set_class_feature(acc, ARM_FEATURE_V7); + set_class_feature(acc, ARM_FEATURE_NEON); + set_class_feature(acc, ARM_FEATURE_THUMB2EE); + set_class_feature(acc, ARM_FEATURE_DUMMY_C15_REGS); + set_class_feature(acc, ARM_FEATURE_EL3); + acc->midr =3D 0x410fc080; + acc->reset_fpsid =3D 0x410330c0; + acc->isar.mvfr0 =3D 0x11110222; + acc->isar.mvfr1 =3D 0x00011111; + acc->ctr =3D 0x82048004; + acc->reset_sctlr =3D 0x00c50078; + acc->isar.id_pfr0 =3D 0x1031; + acc->isar.id_pfr1 =3D 0x11; + acc->isar.id_dfr0 =3D 0x400; + acc->id_afr0 =3D 0; + acc->isar.id_mmfr0 =3D 0x31100003; + acc->isar.id_mmfr1 =3D 0x20000000; + acc->isar.id_mmfr2 =3D 0x01202000; + acc->isar.id_mmfr3 =3D 0x11; + acc->isar.id_isar0 =3D 0x00101111; + acc->isar.id_isar1 =3D 0x12112111; + acc->isar.id_isar2 =3D 0x21232031; + acc->isar.id_isar3 =3D 0x11112131; + acc->isar.id_isar4 =3D 0x00111142; + acc->isar.dbgdidr =3D 0x15141000; + acc->clidr =3D (1 << 27) | (2 << 24) | 3; + acc->ccsidr[0] =3D 0xe007e01a; /* 16k L1 dcache. */ + acc->ccsidr[1] =3D 0x2007e01a; /* 16k L1 icache. */ + acc->ccsidr[2] =3D 0xf0000000; /* No L2 icache. */ + acc->reset_auxcr =3D 2; + acc->isar.reset_pmcr_el0 =3D 0x41002000; + define_arm_cp_regs_with_class(acc, cortexa8_cp_reginfo, NULL); } =20 static const ARMCPRegInfo cortexa9_cp_reginfo[] =3D { @@ -447,45 +447,45 @@ static const ARMCPRegInfo cortexa9_cp_reginfo[] =3D { .access =3D PL1_RW, .resetvalue =3D 0, .type =3D ARM_CP_CONST }, }; =20 -static void cortex_a9_class_init(ARMCPUClass *cpu) +static void cortex_a9_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "arm,cortex-a9"; - set_class_feature(cpu, ARM_FEATURE_V7); - set_class_feature(cpu, ARM_FEATURE_NEON); - set_class_feature(cpu, ARM_FEATURE_THUMB2EE); - set_class_feature(cpu, ARM_FEATURE_EL3); + acc->dtb_compatible =3D "arm,cortex-a9"; + set_class_feature(acc, ARM_FEATURE_V7); + set_class_feature(acc, ARM_FEATURE_NEON); + set_class_feature(acc, ARM_FEATURE_THUMB2EE); + set_class_feature(acc, ARM_FEATURE_EL3); /* * Note that A9 supports the MP extensions even for * A9UP and single-core A9MP (which are both different * and valid configurations; we don't model A9UP). */ - set_class_feature(cpu, ARM_FEATURE_V7MP); - set_class_feature(cpu, ARM_FEATURE_CBAR); - cpu->midr =3D 0x410fc090; - cpu->reset_fpsid =3D 0x41033090; - cpu->isar.mvfr0 =3D 0x11110222; - cpu->isar.mvfr1 =3D 0x01111111; - cpu->ctr =3D 0x80038003; - cpu->reset_sctlr =3D 0x00c50078; - cpu->isar.id_pfr0 =3D 0x1031; - cpu->isar.id_pfr1 =3D 0x11; - cpu->isar.id_dfr0 =3D 0x000; - cpu->id_afr0 =3D 0; - cpu->isar.id_mmfr0 =3D 0x00100103; - cpu->isar.id_mmfr1 =3D 0x20000000; - cpu->isar.id_mmfr2 =3D 0x01230000; - cpu->isar.id_mmfr3 =3D 0x00002111; - cpu->isar.id_isar0 =3D 0x00101111; - cpu->isar.id_isar1 =3D 0x13112111; - cpu->isar.id_isar2 =3D 0x21232041; - cpu->isar.id_isar3 =3D 0x11112131; - cpu->isar.id_isar4 =3D 0x00111142; - cpu->isar.dbgdidr =3D 0x35141000; - cpu->clidr =3D (1 << 27) | (1 << 24) | 3; - cpu->ccsidr[0] =3D 0xe00fe019; /* 16k L1 dcache. */ - cpu->ccsidr[1] =3D 0x200fe019; /* 16k L1 icache. */ - cpu->isar.reset_pmcr_el0 =3D 0x41093000; - define_arm_cp_regs_with_class(cpu, cortexa9_cp_reginfo, NULL); + set_class_feature(acc, ARM_FEATURE_V7MP); + set_class_feature(acc, ARM_FEATURE_CBAR); + acc->midr =3D 0x410fc090; + acc->reset_fpsid =3D 0x41033090; + acc->isar.mvfr0 =3D 0x11110222; + acc->isar.mvfr1 =3D 0x01111111; + acc->ctr =3D 0x80038003; + acc->reset_sctlr =3D 0x00c50078; + acc->isar.id_pfr0 =3D 0x1031; + acc->isar.id_pfr1 =3D 0x11; + acc->isar.id_dfr0 =3D 0x000; + acc->id_afr0 =3D 0; + acc->isar.id_mmfr0 =3D 0x00100103; + acc->isar.id_mmfr1 =3D 0x20000000; + acc->isar.id_mmfr2 =3D 0x01230000; + acc->isar.id_mmfr3 =3D 0x00002111; + acc->isar.id_isar0 =3D 0x00101111; + acc->isar.id_isar1 =3D 0x13112111; + acc->isar.id_isar2 =3D 0x21232041; + acc->isar.id_isar3 =3D 0x11112131; + acc->isar.id_isar4 =3D 0x00111142; + acc->isar.dbgdidr =3D 0x35141000; + acc->clidr =3D (1 << 27) | (1 << 24) | 3; + acc->ccsidr[0] =3D 0xe00fe019; /* 16k L1 dcache. */ + acc->ccsidr[1] =3D 0x200fe019; /* 16k L1 icache. */ + acc->isar.reset_pmcr_el0 =3D 0x41093000; + define_arm_cp_regs_with_class(acc, cortexa9_cp_reginfo, NULL); } =20 #ifndef CONFIG_USER_ONLY @@ -511,106 +511,106 @@ static const ARMCPRegInfo cortexa15_cp_reginfo[] = =3D { .access =3D PL1_RW, .type =3D ARM_CP_CONST, .resetvalue =3D 0 }, }; =20 -static void cortex_a7_class_init(ARMCPUClass *cpu) +static void cortex_a7_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "arm,cortex-a7"; - set_class_feature(cpu, ARM_FEATURE_V7VE); - set_class_feature(cpu, ARM_FEATURE_NEON); - set_class_feature(cpu, ARM_FEATURE_THUMB2EE); - set_class_feature(cpu, ARM_FEATURE_GENERIC_TIMER); - set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); - set_class_feature(cpu, ARM_FEATURE_CBAR_RO); - set_class_feature(cpu, ARM_FEATURE_EL2); - set_class_feature(cpu, ARM_FEATURE_EL3); - set_class_feature(cpu, ARM_FEATURE_PMU); - cpu->kvm_target =3D QEMU_KVM_ARM_TARGET_CORTEX_A7; - cpu->midr =3D 0x410fc075; - cpu->reset_fpsid =3D 0x41023075; - cpu->isar.mvfr0 =3D 0x10110222; - cpu->isar.mvfr1 =3D 0x11111111; - cpu->ctr =3D 0x84448003; - cpu->reset_sctlr =3D 0x00c50078; - cpu->isar.id_pfr0 =3D 0x00001131; - cpu->isar.id_pfr1 =3D 0x00011011; - cpu->isar.id_dfr0 =3D 0x02010555; - cpu->id_afr0 =3D 0x00000000; - cpu->isar.id_mmfr0 =3D 0x10101105; - cpu->isar.id_mmfr1 =3D 0x40000000; - cpu->isar.id_mmfr2 =3D 0x01240000; - cpu->isar.id_mmfr3 =3D 0x02102211; + acc->dtb_compatible =3D "arm,cortex-a7"; + set_class_feature(acc, ARM_FEATURE_V7VE); + set_class_feature(acc, ARM_FEATURE_NEON); + set_class_feature(acc, ARM_FEATURE_THUMB2EE); + set_class_feature(acc, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(acc, ARM_FEATURE_DUMMY_C15_REGS); + set_class_feature(acc, ARM_FEATURE_CBAR_RO); + set_class_feature(acc, ARM_FEATURE_EL2); + set_class_feature(acc, ARM_FEATURE_EL3); + set_class_feature(acc, ARM_FEATURE_PMU); + acc->kvm_target =3D QEMU_KVM_ARM_TARGET_CORTEX_A7; + acc->midr =3D 0x410fc075; + acc->reset_fpsid =3D 0x41023075; + acc->isar.mvfr0 =3D 0x10110222; + acc->isar.mvfr1 =3D 0x11111111; + acc->ctr =3D 0x84448003; + acc->reset_sctlr =3D 0x00c50078; + acc->isar.id_pfr0 =3D 0x00001131; + acc->isar.id_pfr1 =3D 0x00011011; + acc->isar.id_dfr0 =3D 0x02010555; + acc->id_afr0 =3D 0x00000000; + acc->isar.id_mmfr0 =3D 0x10101105; + acc->isar.id_mmfr1 =3D 0x40000000; + acc->isar.id_mmfr2 =3D 0x01240000; + acc->isar.id_mmfr3 =3D 0x02102211; /* * a7_mpcore_r0p5_trm, page 4-4 gives 0x01101110; but * table 4-41 gives 0x02101110, which includes the arm div insns. */ - cpu->isar.id_isar0 =3D 0x02101110; - cpu->isar.id_isar1 =3D 0x13112111; - cpu->isar.id_isar2 =3D 0x21232041; - cpu->isar.id_isar3 =3D 0x11112131; - cpu->isar.id_isar4 =3D 0x10011142; - cpu->isar.dbgdidr =3D 0x3515f005; - cpu->isar.dbgdevid =3D 0x01110f13; - cpu->isar.dbgdevid1 =3D 0x1; - cpu->clidr =3D 0x0a200023; - cpu->ccsidr[0] =3D 0x701fe00a; /* 32K L1 dcache */ - cpu->ccsidr[1] =3D 0x201fe00a; /* 32K L1 icache */ - cpu->ccsidr[2] =3D 0x711fe07a; /* 4096K L2 unified cache */ - cpu->isar.reset_pmcr_el0 =3D 0x41072000; + acc->isar.id_isar0 =3D 0x02101110; + acc->isar.id_isar1 =3D 0x13112111; + acc->isar.id_isar2 =3D 0x21232041; + acc->isar.id_isar3 =3D 0x11112131; + acc->isar.id_isar4 =3D 0x10011142; + acc->isar.dbgdidr =3D 0x3515f005; + acc->isar.dbgdevid =3D 0x01110f13; + acc->isar.dbgdevid1 =3D 0x1; + acc->clidr =3D 0x0a200023; + acc->ccsidr[0] =3D 0x701fe00a; /* 32K L1 dcache */ + acc->ccsidr[1] =3D 0x201fe00a; /* 32K L1 icache */ + acc->ccsidr[2] =3D 0x711fe07a; /* 4096K L2 unified cache */ + acc->isar.reset_pmcr_el0 =3D 0x41072000; =20 /* Same as A15 */ - define_arm_cp_regs_with_class(cpu, cortexa15_cp_reginfo, NULL); + define_arm_cp_regs_with_class(acc, cortexa15_cp_reginfo, NULL); } =20 -static void cortex_a15_class_init(ARMCPUClass *cpu) +static void cortex_a15_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "arm,cortex-a15"; - set_class_feature(cpu, ARM_FEATURE_V7VE); - set_class_feature(cpu, ARM_FEATURE_NEON); - set_class_feature(cpu, ARM_FEATURE_THUMB2EE); - set_class_feature(cpu, ARM_FEATURE_GENERIC_TIMER); - set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); - set_class_feature(cpu, ARM_FEATURE_CBAR_RO); - set_class_feature(cpu, ARM_FEATURE_EL2); - set_class_feature(cpu, ARM_FEATURE_EL3); - set_class_feature(cpu, ARM_FEATURE_PMU); - cpu->kvm_target =3D QEMU_KVM_ARM_TARGET_CORTEX_A15; - /* r4p0 cpu, not requiring expensive tlb flush errata */ - cpu->midr =3D 0x414fc0f0; - cpu->revidr =3D 0x0; - cpu->reset_fpsid =3D 0x410430f0; - cpu->isar.mvfr0 =3D 0x10110222; - cpu->isar.mvfr1 =3D 0x11111111; - cpu->ctr =3D 0x8444c004; - cpu->reset_sctlr =3D 0x00c50078; - cpu->isar.id_pfr0 =3D 0x00001131; - cpu->isar.id_pfr1 =3D 0x00011011; - cpu->isar.id_dfr0 =3D 0x02010555; - cpu->id_afr0 =3D 0x00000000; - cpu->isar.id_mmfr0 =3D 0x10201105; - cpu->isar.id_mmfr1 =3D 0x20000000; - cpu->isar.id_mmfr2 =3D 0x01240000; - cpu->isar.id_mmfr3 =3D 0x02102211; - cpu->isar.id_isar0 =3D 0x02101110; - cpu->isar.id_isar1 =3D 0x13112111; - cpu->isar.id_isar2 =3D 0x21232041; - cpu->isar.id_isar3 =3D 0x11112131; - cpu->isar.id_isar4 =3D 0x10011142; - cpu->isar.dbgdidr =3D 0x3515f021; - cpu->isar.dbgdevid =3D 0x01110f13; - cpu->isar.dbgdevid1 =3D 0x0; - cpu->clidr =3D 0x0a200023; - cpu->ccsidr[0] =3D 0x701fe00a; /* 32K L1 dcache */ - cpu->ccsidr[1] =3D 0x201fe00a; /* 32K L1 icache */ - cpu->ccsidr[2] =3D 0x711fe07a; /* 4096K L2 unified cache */ - cpu->isar.reset_pmcr_el0 =3D 0x410F3000; - define_arm_cp_regs_with_class(cpu, cortexa15_cp_reginfo, NULL); + acc->dtb_compatible =3D "arm,cortex-a15"; + set_class_feature(acc, ARM_FEATURE_V7VE); + set_class_feature(acc, ARM_FEATURE_NEON); + set_class_feature(acc, ARM_FEATURE_THUMB2EE); + set_class_feature(acc, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(acc, ARM_FEATURE_DUMMY_C15_REGS); + set_class_feature(acc, ARM_FEATURE_CBAR_RO); + set_class_feature(acc, ARM_FEATURE_EL2); + set_class_feature(acc, ARM_FEATURE_EL3); + set_class_feature(acc, ARM_FEATURE_PMU); + acc->kvm_target =3D QEMU_KVM_ARM_TARGET_CORTEX_A15; + /* r4p0 acc, not requiring expensive tlb flush errata */ + acc->midr =3D 0x414fc0f0; + acc->revidr =3D 0x0; + acc->reset_fpsid =3D 0x410430f0; + acc->isar.mvfr0 =3D 0x10110222; + acc->isar.mvfr1 =3D 0x11111111; + acc->ctr =3D 0x8444c004; + acc->reset_sctlr =3D 0x00c50078; + acc->isar.id_pfr0 =3D 0x00001131; + acc->isar.id_pfr1 =3D 0x00011011; + acc->isar.id_dfr0 =3D 0x02010555; + acc->id_afr0 =3D 0x00000000; + acc->isar.id_mmfr0 =3D 0x10201105; + acc->isar.id_mmfr1 =3D 0x20000000; + acc->isar.id_mmfr2 =3D 0x01240000; + acc->isar.id_mmfr3 =3D 0x02102211; + acc->isar.id_isar0 =3D 0x02101110; + acc->isar.id_isar1 =3D 0x13112111; + acc->isar.id_isar2 =3D 0x21232041; + acc->isar.id_isar3 =3D 0x11112131; + acc->isar.id_isar4 =3D 0x10011142; + acc->isar.dbgdidr =3D 0x3515f021; + acc->isar.dbgdevid =3D 0x01110f13; + acc->isar.dbgdevid1 =3D 0x0; + acc->clidr =3D 0x0a200023; + acc->ccsidr[0] =3D 0x701fe00a; /* 32K L1 dcache */ + acc->ccsidr[1] =3D 0x201fe00a; /* 32K L1 icache */ + acc->ccsidr[2] =3D 0x711fe07a; /* 4096K L2 unified cache */ + acc->isar.reset_pmcr_el0 =3D 0x410F3000; + define_arm_cp_regs_with_class(acc, cortexa15_cp_reginfo, NULL); } =20 -static void cortex_m0_class_init(ARMCPUClass *cpu) +static void cortex_m0_class_init(ARMCPUClass *acc) { - set_class_feature(cpu, ARM_FEATURE_V6); - set_class_feature(cpu, ARM_FEATURE_M); + set_class_feature(acc, ARM_FEATURE_V6); + set_class_feature(acc, ARM_FEATURE_M); =20 - cpu->midr =3D 0x410cc200; + acc->midr =3D 0x410cc200; =20 /* * These ID register values are not guest visible, because @@ -620,168 +620,168 @@ static void cortex_m0_class_init(ARMCPUClass *cpu) * by looking at ID register fields. We use the same values as * for the M3. */ - cpu->isar.id_pfr0 =3D 0x00000030; - cpu->isar.id_pfr1 =3D 0x00000200; - cpu->isar.id_dfr0 =3D 0x00100000; - cpu->id_afr0 =3D 0x00000000; - cpu->isar.id_mmfr0 =3D 0x00000030; - cpu->isar.id_mmfr1 =3D 0x00000000; - cpu->isar.id_mmfr2 =3D 0x00000000; - cpu->isar.id_mmfr3 =3D 0x00000000; - cpu->isar.id_isar0 =3D 0x01141110; - cpu->isar.id_isar1 =3D 0x02111000; - cpu->isar.id_isar2 =3D 0x21112231; - cpu->isar.id_isar3 =3D 0x01111110; - cpu->isar.id_isar4 =3D 0x01310102; - cpu->isar.id_isar5 =3D 0x00000000; - cpu->isar.id_isar6 =3D 0x00000000; + acc->isar.id_pfr0 =3D 0x00000030; + acc->isar.id_pfr1 =3D 0x00000200; + acc->isar.id_dfr0 =3D 0x00100000; + acc->id_afr0 =3D 0x00000000; + acc->isar.id_mmfr0 =3D 0x00000030; + acc->isar.id_mmfr1 =3D 0x00000000; + acc->isar.id_mmfr2 =3D 0x00000000; + acc->isar.id_mmfr3 =3D 0x00000000; + acc->isar.id_isar0 =3D 0x01141110; + acc->isar.id_isar1 =3D 0x02111000; + acc->isar.id_isar2 =3D 0x21112231; + acc->isar.id_isar3 =3D 0x01111110; + acc->isar.id_isar4 =3D 0x01310102; + acc->isar.id_isar5 =3D 0x00000000; + acc->isar.id_isar6 =3D 0x00000000; } =20 -static void cortex_m3_class_init(ARMCPUClass *cpu) +static void cortex_m3_class_init(ARMCPUClass *acc) { - set_class_feature(cpu, ARM_FEATURE_V7); - set_class_feature(cpu, ARM_FEATURE_M); - set_class_feature(cpu, ARM_FEATURE_M_MAIN); - cpu->midr =3D 0x410fc231; - cpu->pmsav7_dregion =3D 8; - cpu->isar.id_pfr0 =3D 0x00000030; - cpu->isar.id_pfr1 =3D 0x00000200; - cpu->isar.id_dfr0 =3D 0x00100000; - cpu->id_afr0 =3D 0x00000000; - cpu->isar.id_mmfr0 =3D 0x00000030; - cpu->isar.id_mmfr1 =3D 0x00000000; - cpu->isar.id_mmfr2 =3D 0x00000000; - cpu->isar.id_mmfr3 =3D 0x00000000; - cpu->isar.id_isar0 =3D 0x01141110; - cpu->isar.id_isar1 =3D 0x02111000; - cpu->isar.id_isar2 =3D 0x21112231; - cpu->isar.id_isar3 =3D 0x01111110; - cpu->isar.id_isar4 =3D 0x01310102; - cpu->isar.id_isar5 =3D 0x00000000; - cpu->isar.id_isar6 =3D 0x00000000; + set_class_feature(acc, ARM_FEATURE_V7); + set_class_feature(acc, ARM_FEATURE_M); + set_class_feature(acc, ARM_FEATURE_M_MAIN); + acc->midr =3D 0x410fc231; + acc->pmsav7_dregion =3D 8; + acc->isar.id_pfr0 =3D 0x00000030; + acc->isar.id_pfr1 =3D 0x00000200; + acc->isar.id_dfr0 =3D 0x00100000; + acc->id_afr0 =3D 0x00000000; + acc->isar.id_mmfr0 =3D 0x00000030; + acc->isar.id_mmfr1 =3D 0x00000000; + acc->isar.id_mmfr2 =3D 0x00000000; + acc->isar.id_mmfr3 =3D 0x00000000; + acc->isar.id_isar0 =3D 0x01141110; + acc->isar.id_isar1 =3D 0x02111000; + acc->isar.id_isar2 =3D 0x21112231; + acc->isar.id_isar3 =3D 0x01111110; + acc->isar.id_isar4 =3D 0x01310102; + acc->isar.id_isar5 =3D 0x00000000; + acc->isar.id_isar6 =3D 0x00000000; } =20 -static void cortex_m4_class_init(ARMCPUClass *cpu) +static void cortex_m4_class_init(ARMCPUClass *acc) { - set_class_feature(cpu, ARM_FEATURE_V7); - set_class_feature(cpu, ARM_FEATURE_M); - set_class_feature(cpu, ARM_FEATURE_M_MAIN); - set_class_feature(cpu, ARM_FEATURE_THUMB_DSP); - cpu->midr =3D 0x410fc240; /* r0p0 */ - cpu->pmsav7_dregion =3D 8; - cpu->isar.mvfr0 =3D 0x10110021; - cpu->isar.mvfr1 =3D 0x11000011; - cpu->isar.mvfr2 =3D 0x00000000; - cpu->isar.id_pfr0 =3D 0x00000030; - cpu->isar.id_pfr1 =3D 0x00000200; - cpu->isar.id_dfr0 =3D 0x00100000; - cpu->id_afr0 =3D 0x00000000; - cpu->isar.id_mmfr0 =3D 0x00000030; - cpu->isar.id_mmfr1 =3D 0x00000000; - cpu->isar.id_mmfr2 =3D 0x00000000; - cpu->isar.id_mmfr3 =3D 0x00000000; - cpu->isar.id_isar0 =3D 0x01141110; - cpu->isar.id_isar1 =3D 0x02111000; - cpu->isar.id_isar2 =3D 0x21112231; - cpu->isar.id_isar3 =3D 0x01111110; - cpu->isar.id_isar4 =3D 0x01310102; - cpu->isar.id_isar5 =3D 0x00000000; - cpu->isar.id_isar6 =3D 0x00000000; + set_class_feature(acc, ARM_FEATURE_V7); + set_class_feature(acc, ARM_FEATURE_M); + set_class_feature(acc, ARM_FEATURE_M_MAIN); + set_class_feature(acc, ARM_FEATURE_THUMB_DSP); + acc->midr =3D 0x410fc240; /* r0p0 */ + acc->pmsav7_dregion =3D 8; + acc->isar.mvfr0 =3D 0x10110021; + acc->isar.mvfr1 =3D 0x11000011; + acc->isar.mvfr2 =3D 0x00000000; + acc->isar.id_pfr0 =3D 0x00000030; + acc->isar.id_pfr1 =3D 0x00000200; + acc->isar.id_dfr0 =3D 0x00100000; + acc->id_afr0 =3D 0x00000000; + acc->isar.id_mmfr0 =3D 0x00000030; + acc->isar.id_mmfr1 =3D 0x00000000; + acc->isar.id_mmfr2 =3D 0x00000000; + acc->isar.id_mmfr3 =3D 0x00000000; + acc->isar.id_isar0 =3D 0x01141110; + acc->isar.id_isar1 =3D 0x02111000; + acc->isar.id_isar2 =3D 0x21112231; + acc->isar.id_isar3 =3D 0x01111110; + acc->isar.id_isar4 =3D 0x01310102; + acc->isar.id_isar5 =3D 0x00000000; + acc->isar.id_isar6 =3D 0x00000000; } =20 -static void cortex_m7_class_init(ARMCPUClass *cpu) +static void cortex_m7_class_init(ARMCPUClass *acc) { - set_class_feature(cpu, ARM_FEATURE_V7); - set_class_feature(cpu, ARM_FEATURE_M); - set_class_feature(cpu, ARM_FEATURE_M_MAIN); - set_class_feature(cpu, ARM_FEATURE_THUMB_DSP); - cpu->midr =3D 0x411fc272; /* r1p2 */ - cpu->pmsav7_dregion =3D 8; - cpu->isar.mvfr0 =3D 0x10110221; - cpu->isar.mvfr1 =3D 0x12000011; - cpu->isar.mvfr2 =3D 0x00000040; - cpu->isar.id_pfr0 =3D 0x00000030; - cpu->isar.id_pfr1 =3D 0x00000200; - cpu->isar.id_dfr0 =3D 0x00100000; - cpu->id_afr0 =3D 0x00000000; - cpu->isar.id_mmfr0 =3D 0x00100030; - cpu->isar.id_mmfr1 =3D 0x00000000; - cpu->isar.id_mmfr2 =3D 0x01000000; - cpu->isar.id_mmfr3 =3D 0x00000000; - cpu->isar.id_isar0 =3D 0x01101110; - cpu->isar.id_isar1 =3D 0x02112000; - cpu->isar.id_isar2 =3D 0x20232231; - cpu->isar.id_isar3 =3D 0x01111131; - cpu->isar.id_isar4 =3D 0x01310132; - cpu->isar.id_isar5 =3D 0x00000000; - cpu->isar.id_isar6 =3D 0x00000000; + set_class_feature(acc, ARM_FEATURE_V7); + set_class_feature(acc, ARM_FEATURE_M); + set_class_feature(acc, ARM_FEATURE_M_MAIN); + set_class_feature(acc, ARM_FEATURE_THUMB_DSP); + acc->midr =3D 0x411fc272; /* r1p2 */ + acc->pmsav7_dregion =3D 8; + acc->isar.mvfr0 =3D 0x10110221; + acc->isar.mvfr1 =3D 0x12000011; + acc->isar.mvfr2 =3D 0x00000040; + acc->isar.id_pfr0 =3D 0x00000030; + acc->isar.id_pfr1 =3D 0x00000200; + acc->isar.id_dfr0 =3D 0x00100000; + acc->id_afr0 =3D 0x00000000; + acc->isar.id_mmfr0 =3D 0x00100030; + acc->isar.id_mmfr1 =3D 0x00000000; + acc->isar.id_mmfr2 =3D 0x01000000; + acc->isar.id_mmfr3 =3D 0x00000000; + acc->isar.id_isar0 =3D 0x01101110; + acc->isar.id_isar1 =3D 0x02112000; + acc->isar.id_isar2 =3D 0x20232231; + acc->isar.id_isar3 =3D 0x01111131; + acc->isar.id_isar4 =3D 0x01310132; + acc->isar.id_isar5 =3D 0x00000000; + acc->isar.id_isar6 =3D 0x00000000; } =20 -static void cortex_m33_class_init(ARMCPUClass *cpu) +static void cortex_m33_class_init(ARMCPUClass *acc) { - set_class_feature(cpu, ARM_FEATURE_V8); - set_class_feature(cpu, ARM_FEATURE_M); - set_class_feature(cpu, ARM_FEATURE_M_MAIN); - set_class_feature(cpu, ARM_FEATURE_M_SECURITY); - set_class_feature(cpu, ARM_FEATURE_THUMB_DSP); - cpu->midr =3D 0x410fd213; /* r0p3 */ - cpu->pmsav7_dregion =3D 16; - cpu->sau_sregion =3D 8; - cpu->isar.mvfr0 =3D 0x10110021; - cpu->isar.mvfr1 =3D 0x11000011; - cpu->isar.mvfr2 =3D 0x00000040; - cpu->isar.id_pfr0 =3D 0x00000030; - cpu->isar.id_pfr1 =3D 0x00000210; - cpu->isar.id_dfr0 =3D 0x00200000; - cpu->id_afr0 =3D 0x00000000; - cpu->isar.id_mmfr0 =3D 0x00101F40; - cpu->isar.id_mmfr1 =3D 0x00000000; - cpu->isar.id_mmfr2 =3D 0x01000000; - cpu->isar.id_mmfr3 =3D 0x00000000; - cpu->isar.id_isar0 =3D 0x01101110; - cpu->isar.id_isar1 =3D 0x02212000; - cpu->isar.id_isar2 =3D 0x20232232; - cpu->isar.id_isar3 =3D 0x01111131; - cpu->isar.id_isar4 =3D 0x01310132; - cpu->isar.id_isar5 =3D 0x00000000; - cpu->isar.id_isar6 =3D 0x00000000; - cpu->clidr =3D 0x00000000; - cpu->ctr =3D 0x8000c000; + set_class_feature(acc, ARM_FEATURE_V8); + set_class_feature(acc, ARM_FEATURE_M); + set_class_feature(acc, ARM_FEATURE_M_MAIN); + set_class_feature(acc, ARM_FEATURE_M_SECURITY); + set_class_feature(acc, ARM_FEATURE_THUMB_DSP); + acc->midr =3D 0x410fd213; /* r0p3 */ + acc->pmsav7_dregion =3D 16; + acc->sau_sregion =3D 8; + acc->isar.mvfr0 =3D 0x10110021; + acc->isar.mvfr1 =3D 0x11000011; + acc->isar.mvfr2 =3D 0x00000040; + acc->isar.id_pfr0 =3D 0x00000030; + acc->isar.id_pfr1 =3D 0x00000210; + acc->isar.id_dfr0 =3D 0x00200000; + acc->id_afr0 =3D 0x00000000; + acc->isar.id_mmfr0 =3D 0x00101F40; + acc->isar.id_mmfr1 =3D 0x00000000; + acc->isar.id_mmfr2 =3D 0x01000000; + acc->isar.id_mmfr3 =3D 0x00000000; + acc->isar.id_isar0 =3D 0x01101110; + acc->isar.id_isar1 =3D 0x02212000; + acc->isar.id_isar2 =3D 0x20232232; + acc->isar.id_isar3 =3D 0x01111131; + acc->isar.id_isar4 =3D 0x01310132; + acc->isar.id_isar5 =3D 0x00000000; + acc->isar.id_isar6 =3D 0x00000000; + acc->clidr =3D 0x00000000; + acc->ctr =3D 0x8000c000; } =20 -static void cortex_m55_class_init(ARMCPUClass *cpu) +static void cortex_m55_class_init(ARMCPUClass *acc) { - set_class_feature(cpu, ARM_FEATURE_V8); - set_class_feature(cpu, ARM_FEATURE_V8_1M); - set_class_feature(cpu, ARM_FEATURE_M); - set_class_feature(cpu, ARM_FEATURE_M_MAIN); - set_class_feature(cpu, ARM_FEATURE_M_SECURITY); - set_class_feature(cpu, ARM_FEATURE_THUMB_DSP); - cpu->midr =3D 0x410fd221; /* r0p1 */ - cpu->revidr =3D 0; - cpu->pmsav7_dregion =3D 16; - cpu->sau_sregion =3D 8; + set_class_feature(acc, ARM_FEATURE_V8); + set_class_feature(acc, ARM_FEATURE_V8_1M); + set_class_feature(acc, ARM_FEATURE_M); + set_class_feature(acc, ARM_FEATURE_M_MAIN); + set_class_feature(acc, ARM_FEATURE_M_SECURITY); + set_class_feature(acc, ARM_FEATURE_THUMB_DSP); + acc->midr =3D 0x410fd221; /* r0p1 */ + acc->revidr =3D 0; + acc->pmsav7_dregion =3D 16; + acc->sau_sregion =3D 8; /* These are the MVFR* values for the FPU + full MVE configuration */ - cpu->isar.mvfr0 =3D 0x10110221; - cpu->isar.mvfr1 =3D 0x12100211; - cpu->isar.mvfr2 =3D 0x00000040; - cpu->isar.id_pfr0 =3D 0x20000030; - cpu->isar.id_pfr1 =3D 0x00000230; - cpu->isar.id_dfr0 =3D 0x10200000; - cpu->id_afr0 =3D 0x00000000; - cpu->isar.id_mmfr0 =3D 0x00111040; - cpu->isar.id_mmfr1 =3D 0x00000000; - cpu->isar.id_mmfr2 =3D 0x01000000; - cpu->isar.id_mmfr3 =3D 0x00000011; - cpu->isar.id_isar0 =3D 0x01103110; - cpu->isar.id_isar1 =3D 0x02212000; - cpu->isar.id_isar2 =3D 0x20232232; - cpu->isar.id_isar3 =3D 0x01111131; - cpu->isar.id_isar4 =3D 0x01310132; - cpu->isar.id_isar5 =3D 0x00000000; - cpu->isar.id_isar6 =3D 0x00000000; - cpu->clidr =3D 0x00000000; /* caches not implemented */ - cpu->ctr =3D 0x8303c003; + acc->isar.mvfr0 =3D 0x10110221; + acc->isar.mvfr1 =3D 0x12100211; + acc->isar.mvfr2 =3D 0x00000040; + acc->isar.id_pfr0 =3D 0x20000030; + acc->isar.id_pfr1 =3D 0x00000230; + acc->isar.id_dfr0 =3D 0x10200000; + acc->id_afr0 =3D 0x00000000; + acc->isar.id_mmfr0 =3D 0x00111040; + acc->isar.id_mmfr1 =3D 0x00000000; + acc->isar.id_mmfr2 =3D 0x01000000; + acc->isar.id_mmfr3 =3D 0x00000011; + acc->isar.id_isar0 =3D 0x01103110; + acc->isar.id_isar1 =3D 0x02212000; + acc->isar.id_isar2 =3D 0x20232232; + acc->isar.id_isar3 =3D 0x01111131; + acc->isar.id_isar4 =3D 0x01310132; + acc->isar.id_isar5 =3D 0x00000000; + acc->isar.id_isar6 =3D 0x00000000; + acc->clidr =3D 0x00000000; /* caches not implemented */ + acc->ctr =3D 0x8303c003; } =20 static const ARMCPRegInfo cortexr5_cp_reginfo[] =3D { @@ -794,180 +794,180 @@ static const ARMCPRegInfo cortexr5_cp_reginfo[] =3D= { .opc2 =3D 0, .access =3D PL1_W, .type =3D ARM_CP_NOP }, }; =20 -static void cortex_r5_class_init(ARMCPUClass *cpu) +static void cortex_r5_class_init(ARMCPUClass *acc) { - set_class_feature(cpu, ARM_FEATURE_V7); - set_class_feature(cpu, ARM_FEATURE_V7MP); - set_class_feature(cpu, ARM_FEATURE_PMSA); - set_class_feature(cpu, ARM_FEATURE_PMU); - cpu->midr =3D 0x411fc153; /* r1p3 */ - cpu->isar.id_pfr0 =3D 0x0131; - cpu->isar.id_pfr1 =3D 0x001; - cpu->isar.id_dfr0 =3D 0x010400; - cpu->id_afr0 =3D 0x0; - cpu->isar.id_mmfr0 =3D 0x0210030; - cpu->isar.id_mmfr1 =3D 0x00000000; - cpu->isar.id_mmfr2 =3D 0x01200000; - cpu->isar.id_mmfr3 =3D 0x0211; - cpu->isar.id_isar0 =3D 0x02101111; - cpu->isar.id_isar1 =3D 0x13112111; - cpu->isar.id_isar2 =3D 0x21232141; - cpu->isar.id_isar3 =3D 0x01112131; - cpu->isar.id_isar4 =3D 0x0010142; - cpu->isar.id_isar5 =3D 0x0; - cpu->isar.id_isar6 =3D 0x0; - cpu->pmsav7_dregion =3D 16; - cpu->isar.reset_pmcr_el0 =3D 0x41151800; - define_arm_cp_regs_with_class(cpu, cortexr5_cp_reginfo, NULL); + set_class_feature(acc, ARM_FEATURE_V7); + set_class_feature(acc, ARM_FEATURE_V7MP); + set_class_feature(acc, ARM_FEATURE_PMSA); + set_class_feature(acc, ARM_FEATURE_PMU); + acc->midr =3D 0x411fc153; /* r1p3 */ + acc->isar.id_pfr0 =3D 0x0131; + acc->isar.id_pfr1 =3D 0x001; + acc->isar.id_dfr0 =3D 0x010400; + acc->id_afr0 =3D 0x0; + acc->isar.id_mmfr0 =3D 0x0210030; + acc->isar.id_mmfr1 =3D 0x00000000; + acc->isar.id_mmfr2 =3D 0x01200000; + acc->isar.id_mmfr3 =3D 0x0211; + acc->isar.id_isar0 =3D 0x02101111; + acc->isar.id_isar1 =3D 0x13112111; + acc->isar.id_isar2 =3D 0x21232141; + acc->isar.id_isar3 =3D 0x01112131; + acc->isar.id_isar4 =3D 0x0010142; + acc->isar.id_isar5 =3D 0x0; + acc->isar.id_isar6 =3D 0x0; + acc->pmsav7_dregion =3D 16; + acc->isar.reset_pmcr_el0 =3D 0x41151800; + define_arm_cp_regs_with_class(acc, cortexr5_cp_reginfo, NULL); } =20 -static void cortex_r5f_class_init(ARMCPUClass *cpu) +static void cortex_r5f_class_init(ARMCPUClass *acc) { - cortex_r5_class_init(cpu); - cpu->isar.mvfr0 =3D 0x10110221; - cpu->isar.mvfr1 =3D 0x00000011; + cortex_r5_class_init(acc); + acc->isar.mvfr0 =3D 0x10110221; + acc->isar.mvfr1 =3D 0x00000011; } =20 -static void ti925t_class_init(ARMCPUClass *cpu) +static void ti925t_class_init(ARMCPUClass *acc) { - set_class_feature(cpu, ARM_FEATURE_V4T); - set_class_feature(cpu, ARM_FEATURE_OMAPCP); - cpu->midr =3D ARM_CPUID_TI925T; - cpu->ctr =3D 0x5109149; - cpu->reset_sctlr =3D 0x00000070; + set_class_feature(acc, ARM_FEATURE_V4T); + set_class_feature(acc, ARM_FEATURE_OMAPCP); + acc->midr =3D ARM_CPUID_TI925T; + acc->ctr =3D 0x5109149; + acc->reset_sctlr =3D 0x00000070; } =20 -static void sa1100_class_init(ARMCPUClass *cpu) +static void sa1100_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "intel,sa1100"; - set_class_feature(cpu, ARM_FEATURE_STRONGARM); - set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); - cpu->midr =3D 0x4401A11B; - cpu->reset_sctlr =3D 0x00000070; + acc->dtb_compatible =3D "intel,sa1100"; + set_class_feature(acc, ARM_FEATURE_STRONGARM); + set_class_feature(acc, ARM_FEATURE_DUMMY_C15_REGS); + acc->midr =3D 0x4401A11B; + acc->reset_sctlr =3D 0x00000070; } =20 -static void sa1110_class_init(ARMCPUClass *cpu) +static void sa1110_class_init(ARMCPUClass *acc) { - set_class_feature(cpu, ARM_FEATURE_STRONGARM); - set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); - cpu->midr =3D 0x6901B119; - cpu->reset_sctlr =3D 0x00000070; + set_class_feature(acc, ARM_FEATURE_STRONGARM); + set_class_feature(acc, ARM_FEATURE_DUMMY_C15_REGS); + acc->midr =3D 0x6901B119; + acc->reset_sctlr =3D 0x00000070; } =20 -static void pxa250_class_init(ARMCPUClass *cpu) +static void pxa250_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "marvell,xscale"; - set_class_feature(cpu, ARM_FEATURE_V5); - set_class_feature(cpu, ARM_FEATURE_XSCALE); - cpu->midr =3D 0x69052100; - cpu->ctr =3D 0xd172172; - cpu->reset_sctlr =3D 0x00000078; + acc->dtb_compatible =3D "marvell,xscale"; + set_class_feature(acc, ARM_FEATURE_V5); + set_class_feature(acc, ARM_FEATURE_XSCALE); + acc->midr =3D 0x69052100; + acc->ctr =3D 0xd172172; + acc->reset_sctlr =3D 0x00000078; } =20 -static void pxa255_class_init(ARMCPUClass *cpu) +static void pxa255_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "marvell,xscale"; - set_class_feature(cpu, ARM_FEATURE_V5); - set_class_feature(cpu, ARM_FEATURE_XSCALE); - cpu->midr =3D 0x69052d00; - cpu->ctr =3D 0xd172172; - cpu->reset_sctlr =3D 0x00000078; + acc->dtb_compatible =3D "marvell,xscale"; + set_class_feature(acc, ARM_FEATURE_V5); + set_class_feature(acc, ARM_FEATURE_XSCALE); + acc->midr =3D 0x69052d00; + acc->ctr =3D 0xd172172; + acc->reset_sctlr =3D 0x00000078; } =20 -static void pxa260_class_init(ARMCPUClass *cpu) +static void pxa260_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "marvell,xscale"; - set_class_feature(cpu, ARM_FEATURE_V5); - set_class_feature(cpu, ARM_FEATURE_XSCALE); - cpu->midr =3D 0x69052903; - cpu->ctr =3D 0xd172172; - cpu->reset_sctlr =3D 0x00000078; + acc->dtb_compatible =3D "marvell,xscale"; + set_class_feature(acc, ARM_FEATURE_V5); + set_class_feature(acc, ARM_FEATURE_XSCALE); + acc->midr =3D 0x69052903; + acc->ctr =3D 0xd172172; + acc->reset_sctlr =3D 0x00000078; } =20 -static void pxa261_class_init(ARMCPUClass *cpu) +static void pxa261_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "marvell,xscale"; - set_class_feature(cpu, ARM_FEATURE_V5); - set_class_feature(cpu, ARM_FEATURE_XSCALE); - cpu->midr =3D 0x69052d05; - cpu->ctr =3D 0xd172172; - cpu->reset_sctlr =3D 0x00000078; + acc->dtb_compatible =3D "marvell,xscale"; + set_class_feature(acc, ARM_FEATURE_V5); + set_class_feature(acc, ARM_FEATURE_XSCALE); + acc->midr =3D 0x69052d05; + acc->ctr =3D 0xd172172; + acc->reset_sctlr =3D 0x00000078; } =20 -static void pxa262_class_init(ARMCPUClass *cpu) +static void pxa262_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "marvell,xscale"; - set_class_feature(cpu, ARM_FEATURE_V5); - set_class_feature(cpu, ARM_FEATURE_XSCALE); - cpu->midr =3D 0x69052d06; - cpu->ctr =3D 0xd172172; - cpu->reset_sctlr =3D 0x00000078; + acc->dtb_compatible =3D "marvell,xscale"; + set_class_feature(acc, ARM_FEATURE_V5); + set_class_feature(acc, ARM_FEATURE_XSCALE); + acc->midr =3D 0x69052d06; + acc->ctr =3D 0xd172172; + acc->reset_sctlr =3D 0x00000078; } =20 -static void pxa270a0_class_init(ARMCPUClass *cpu) +static void pxa270a0_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "marvell,xscale"; - set_class_feature(cpu, ARM_FEATURE_V5); - set_class_feature(cpu, ARM_FEATURE_XSCALE); - set_class_feature(cpu, ARM_FEATURE_IWMMXT); - cpu->midr =3D 0x69054110; - cpu->ctr =3D 0xd172172; - cpu->reset_sctlr =3D 0x00000078; + acc->dtb_compatible =3D "marvell,xscale"; + set_class_feature(acc, ARM_FEATURE_V5); + set_class_feature(acc, ARM_FEATURE_XSCALE); + set_class_feature(acc, ARM_FEATURE_IWMMXT); + acc->midr =3D 0x69054110; + acc->ctr =3D 0xd172172; + acc->reset_sctlr =3D 0x00000078; } =20 -static void pxa270a1_class_init(ARMCPUClass *cpu) +static void pxa270a1_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "marvell,xscale"; - set_class_feature(cpu, ARM_FEATURE_V5); - set_class_feature(cpu, ARM_FEATURE_XSCALE); - set_class_feature(cpu, ARM_FEATURE_IWMMXT); - cpu->midr =3D 0x69054111; - cpu->ctr =3D 0xd172172; - cpu->reset_sctlr =3D 0x00000078; + acc->dtb_compatible =3D "marvell,xscale"; + set_class_feature(acc, ARM_FEATURE_V5); + set_class_feature(acc, ARM_FEATURE_XSCALE); + set_class_feature(acc, ARM_FEATURE_IWMMXT); + acc->midr =3D 0x69054111; + acc->ctr =3D 0xd172172; + acc->reset_sctlr =3D 0x00000078; } =20 -static void pxa270b0_class_init(ARMCPUClass *cpu) +static void pxa270b0_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "marvell,xscale"; - set_class_feature(cpu, ARM_FEATURE_V5); - set_class_feature(cpu, ARM_FEATURE_XSCALE); - set_class_feature(cpu, ARM_FEATURE_IWMMXT); - cpu->midr =3D 0x69054112; - cpu->ctr =3D 0xd172172; - cpu->reset_sctlr =3D 0x00000078; + acc->dtb_compatible =3D "marvell,xscale"; + set_class_feature(acc, ARM_FEATURE_V5); + set_class_feature(acc, ARM_FEATURE_XSCALE); + set_class_feature(acc, ARM_FEATURE_IWMMXT); + acc->midr =3D 0x69054112; + acc->ctr =3D 0xd172172; + acc->reset_sctlr =3D 0x00000078; } =20 -static void pxa270b1_class_init(ARMCPUClass *cpu) +static void pxa270b1_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "marvell,xscale"; - set_class_feature(cpu, ARM_FEATURE_V5); - set_class_feature(cpu, ARM_FEATURE_XSCALE); - set_class_feature(cpu, ARM_FEATURE_IWMMXT); - cpu->midr =3D 0x69054113; - cpu->ctr =3D 0xd172172; - cpu->reset_sctlr =3D 0x00000078; + acc->dtb_compatible =3D "marvell,xscale"; + set_class_feature(acc, ARM_FEATURE_V5); + set_class_feature(acc, ARM_FEATURE_XSCALE); + set_class_feature(acc, ARM_FEATURE_IWMMXT); + acc->midr =3D 0x69054113; + acc->ctr =3D 0xd172172; + acc->reset_sctlr =3D 0x00000078; } =20 -static void pxa270c0_class_init(ARMCPUClass *cpu) +static void pxa270c0_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "marvell,xscale"; - set_class_feature(cpu, ARM_FEATURE_V5); - set_class_feature(cpu, ARM_FEATURE_XSCALE); - set_class_feature(cpu, ARM_FEATURE_IWMMXT); - cpu->midr =3D 0x69054114; - cpu->ctr =3D 0xd172172; - cpu->reset_sctlr =3D 0x00000078; + acc->dtb_compatible =3D "marvell,xscale"; + set_class_feature(acc, ARM_FEATURE_V5); + set_class_feature(acc, ARM_FEATURE_XSCALE); + set_class_feature(acc, ARM_FEATURE_IWMMXT); + acc->midr =3D 0x69054114; + acc->ctr =3D 0xd172172; + acc->reset_sctlr =3D 0x00000078; } =20 -static void pxa270c5_class_init(ARMCPUClass *cpu) +static void pxa270c5_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible =3D "marvell,xscale"; - set_class_feature(cpu, ARM_FEATURE_V5); - set_class_feature(cpu, ARM_FEATURE_XSCALE); - set_class_feature(cpu, ARM_FEATURE_IWMMXT); - cpu->midr =3D 0x69054117; - cpu->ctr =3D 0xd172172; - cpu->reset_sctlr =3D 0x00000078; + acc->dtb_compatible =3D "marvell,xscale"; + set_class_feature(acc, ARM_FEATURE_V5); + set_class_feature(acc, ARM_FEATURE_XSCALE); + set_class_feature(acc, ARM_FEATURE_IWMMXT); + acc->midr =3D 0x69054117; + acc->ctr =3D 0xd172172; + acc->reset_sctlr =3D 0x00000078; } =20 #ifdef CONFIG_TCG @@ -1010,51 +1010,51 @@ static void arm_v7m_class_init(ObjectClass *oc, voi= d *data) * The version of '-cpu max' for qemu-system-aarch64 is defined in cpu64.c; * this only needs to handle 32 bits, and need not care about KVM. */ -static void arm_max_class_init(ARMCPUClass *cpu) +static void arm_max_class_init(ARMCPUClass *acc) { /* aarch64_a57_class_init, advertising none of the aarch64 features */ - cpu->dtb_compatible =3D "arm,cortex-a57"; - set_class_feature(cpu, ARM_FEATURE_V8); - set_class_feature(cpu, ARM_FEATURE_NEON); - set_class_feature(cpu, ARM_FEATURE_GENERIC_TIMER); - set_class_feature(cpu, ARM_FEATURE_CBAR_RO); - set_class_feature(cpu, ARM_FEATURE_EL2); - set_class_feature(cpu, ARM_FEATURE_EL3); - set_class_feature(cpu, ARM_FEATURE_PMU); - cpu->midr =3D 0x411fd070; - cpu->revidr =3D 0x00000000; - cpu->reset_fpsid =3D 0x41034070; - cpu->isar.mvfr0 =3D 0x10110222; - cpu->isar.mvfr1 =3D 0x12111111; - cpu->isar.mvfr2 =3D 0x00000043; - cpu->ctr =3D 0x8444c004; - cpu->reset_sctlr =3D 0x00c50838; - cpu->isar.id_pfr0 =3D 0x00000131; - cpu->isar.id_pfr1 =3D 0x00011011; - cpu->isar.id_dfr0 =3D 0x03010066; - cpu->id_afr0 =3D 0x00000000; - cpu->isar.id_mmfr0 =3D 0x10101105; - cpu->isar.id_mmfr1 =3D 0x40000000; - cpu->isar.id_mmfr2 =3D 0x01260000; - cpu->isar.id_mmfr3 =3D 0x02102211; - cpu->isar.id_isar0 =3D 0x02101110; - cpu->isar.id_isar1 =3D 0x13112111; - cpu->isar.id_isar2 =3D 0x21232042; - cpu->isar.id_isar3 =3D 0x01112131; - cpu->isar.id_isar4 =3D 0x00011142; - cpu->isar.id_isar5 =3D 0x00011121; - cpu->isar.id_isar6 =3D 0; - cpu->isar.dbgdidr =3D 0x3516d000; - cpu->isar.dbgdevid =3D 0x00110f13; - cpu->isar.dbgdevid1 =3D 0x2; - cpu->isar.reset_pmcr_el0 =3D 0x41013000; - cpu->clidr =3D 0x0a200023; - cpu->ccsidr[0] =3D 0x701fe00a; /* 32KB L1 dcache */ - cpu->ccsidr[1] =3D 0x201fe012; /* 48KB L1 icache */ - cpu->ccsidr[2] =3D 0x70ffe07a; /* 2048KB L2 cache */ - define_cortex_a72_a57_a53_cp_reginfo(cpu); + acc->dtb_compatible =3D "arm,cortex-a57"; + set_class_feature(acc, ARM_FEATURE_V8); + set_class_feature(acc, ARM_FEATURE_NEON); + set_class_feature(acc, ARM_FEATURE_GENERIC_TIMER); + set_class_feature(acc, ARM_FEATURE_CBAR_RO); + set_class_feature(acc, ARM_FEATURE_EL2); + set_class_feature(acc, ARM_FEATURE_EL3); + set_class_feature(acc, ARM_FEATURE_PMU); + acc->midr =3D 0x411fd070; + acc->revidr =3D 0x00000000; + acc->reset_fpsid =3D 0x41034070; + acc->isar.mvfr0 =3D 0x10110222; + acc->isar.mvfr1 =3D 0x12111111; + acc->isar.mvfr2 =3D 0x00000043; + acc->ctr =3D 0x8444c004; + acc->reset_sctlr =3D 0x00c50838; + acc->isar.id_pfr0 =3D 0x00000131; + acc->isar.id_pfr1 =3D 0x00011011; + acc->isar.id_dfr0 =3D 0x03010066; + acc->id_afr0 =3D 0x00000000; + acc->isar.id_mmfr0 =3D 0x10101105; + acc->isar.id_mmfr1 =3D 0x40000000; + acc->isar.id_mmfr2 =3D 0x01260000; + acc->isar.id_mmfr3 =3D 0x02102211; + acc->isar.id_isar0 =3D 0x02101110; + acc->isar.id_isar1 =3D 0x13112111; + acc->isar.id_isar2 =3D 0x21232042; + acc->isar.id_isar3 =3D 0x01112131; + acc->isar.id_isar4 =3D 0x00011142; + acc->isar.id_isar5 =3D 0x00011121; + acc->isar.id_isar6 =3D 0; + acc->isar.dbgdidr =3D 0x3516d000; + acc->isar.dbgdevid =3D 0x00110f13; + acc->isar.dbgdevid1 =3D 0x2; + acc->isar.reset_pmcr_el0 =3D 0x41013000; + acc->clidr =3D 0x0a200023; + acc->ccsidr[0] =3D 0x701fe00a; /* 32KB L1 dcache */ + acc->ccsidr[1] =3D 0x201fe012; /* 48KB L1 icache */ + acc->ccsidr[2] =3D 0x70ffe07a; /* 2048KB L2 cache */ + define_cortex_a72_a57_a53_cp_reginfo(acc); =20 - aa32_max_features(cpu); + aa32_max_features(acc); =20 #ifdef CONFIG_USER_ONLY /* @@ -1062,7 +1062,7 @@ static void arm_max_class_init(ARMCPUClass *cpu) * Only do this for user-mode, where -cpu max is the default, so that * older v6 and v7 programs are more likely to work without adjustment. */ - cpu->isar.mvfr0 =3D FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); + acc->isar.mvfr0 =3D FIELD_DP32(acc->isar.mvfr0, MVFR0, FPSHVEC, 1); #endif } #endif /* !TARGET_AARCH64 */ --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770495; cv=none; d=zohomail.com; s=zohoarc; b=CRxPAl4LiOb7en+gDpiVAYTg51M4SDNoR27WV3WaHE4QMhdguhLwdbFcPDAm0Qwp2r+EMpD/GhCDbeEry4L66wkh9ipI/pl1yPUNSspDfgy5YsbnFdICZHcENMVTLs+oadIrbxNJJo4shL+ThfO8mqpl0j65g2NZB00FYzreWC8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770495; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=LAidI3WiD+zjwr6by+YYhTTuNMWH39p6ritGq9qXxUI=; b=XAR70flvAsMMg1TNjFD7sWkcprNUFTDnsrKNxLSNMqG59KXHlgSQi8gjEULvG0RZP8kpHJ0WJwF/KyblmZXpmC5R4plzKglh2CihcOgKAZJubaudoiwJd8fnFMafe/IQqc9kC1py5AGy4Ry+jpIzDtYBny8FfrPBO1MdfIEnqSU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770495960279.36601393944727; Tue, 3 Jan 2023 10:28:15 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrj-0000UH-3Q; Tue, 03 Jan 2023 13:18:23 -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 1pClrZ-00006z-Cz for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:14 -0500 Received: from mail-yw1-x112f.google.com ([2607:f8b0:4864:20::112f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClrX-0005Jk-UU for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:13 -0500 Received: by mail-yw1-x112f.google.com with SMTP id 00721157ae682-466c5fb1c39so435156267b3.10 for ; Tue, 03 Jan 2023 10:18:11 -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.18.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:18:10 -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=LAidI3WiD+zjwr6by+YYhTTuNMWH39p6ritGq9qXxUI=; b=kCyD9Mi7i/IPif+tk7C0ea2vhfSsSePSMQ4VpxXUYxNopCBXGFWj6wF5br+VwXgWRp 946e35stI1DLZwbf/SmOxDQDG408CLuwchnMbi6q5FEUecaYh6B2ORZdj32IxghzuRVj cdeyyE7nZF2RY9ZRxEVcdaOhCKRgt2iwNGGUHiAzXQlZMX6DJzs9dAc9eFS4EpHRdGg5 fePN6MENJ7JKNXUq0zHuCVo/fmPonCWKrY15pUWcMpkhLWHsnDyl9163VrvnSt9O9jvp uiXhP/LbxKOPmnMy2DuWevNsxikttSw5Rvl0qkVQXECyJmUGmzdJcS6P2D9uq37dw1D3 Llmg== 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=LAidI3WiD+zjwr6by+YYhTTuNMWH39p6ritGq9qXxUI=; b=g1wtnEcPRy4kigDA/Ady7K9ZoqVKPnYunqTGSia3MYOavmIGAN3XSMm9ezo9PyCCD7 ULNcxmr1kPwuD87u+0geLvV+YtCZ20HeeNgRUJ4+AUn4QHrjEVvdbHrMkAvMGA+NC40y FeUfHo6C9xsP5zX+KQFUwAbw8vLndIBHp4bWBGDu96qCJQzjfJT40igI6XTK6o+CQ5TW zHrEUrs2e37K4uYtgnHQIsXZ+dYv3GaV7PdJMjRJHk/Obx9q3vEbuaEAS4wgS4CyCFmc TSMvgV1R3ToOEuI+Rm9fEdvqK3jRepRrDt4CMhckLqTBVjaoYQ9Qb0ubTxQUhtUsBfb7 oU2g== X-Gm-Message-State: AFqh2kpnHPZZQr+N146ZrAf8ZCet4AyogBIa+NNQsyBwvk9EgvA2u9gA rvOzbbEWKqim8Cf7PNvPl6R/yZoc0gMqfEA6rvg= X-Google-Smtp-Source: AMrXdXtqL/AIft81E1rhze0dCIIutyTgvgMZ+FqJ1O3aUeDFnXDQQNwTruAg6vhE6ZrIyPriC3hYgQ== X-Received: by 2002:a81:1e4a:0:b0:48f:a921:40eb with SMTP id e71-20020a811e4a000000b0048fa92140ebmr16168277ywe.35.1672769890698; Tue, 03 Jan 2023 10:18:10 -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 27/40] target/arm: Split out strongarm_class_init Date: Tue, 3 Jan 2023 10:16:33 -0800 Message-Id: <20230103181646.55711-28-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::112f; envelope-from=richard.henderson@linaro.org; helo=mail-yw1-x112f.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770498161100005 Content-Type: text/plain; charset="utf-8" Use an intermediate function to share code between sa1100_class_init and sa1110_class_init. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/cpu_tcg.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c index 1ef825b39e..c6d50f326e 100644 --- a/target/arm/cpu_tcg.c +++ b/target/arm/cpu_tcg.c @@ -837,21 +837,24 @@ static void ti925t_class_init(ARMCPUClass *acc) acc->reset_sctlr =3D 0x00000070; } =20 -static void sa1100_class_init(ARMCPUClass *acc) +static void strongarm_class_init(ARMCPUClass *acc) { - acc->dtb_compatible =3D "intel,sa1100"; set_class_feature(acc, ARM_FEATURE_STRONGARM); set_class_feature(acc, ARM_FEATURE_DUMMY_C15_REGS); - acc->midr =3D 0x4401A11B; acc->reset_sctlr =3D 0x00000070; } =20 +static void sa1100_class_init(ARMCPUClass *acc) +{ + strongarm_class_init(acc); + acc->dtb_compatible =3D "intel,sa1100"; + acc->midr =3D 0x4401A11B; +} + static void sa1110_class_init(ARMCPUClass *acc) { - set_class_feature(acc, ARM_FEATURE_STRONGARM); - set_class_feature(acc, ARM_FEATURE_DUMMY_C15_REGS); + strongarm_class_init(acc); acc->midr =3D 0x6901B119; - acc->reset_sctlr =3D 0x00000070; } =20 static void pxa250_class_init(ARMCPUClass *acc) --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770520; cv=none; d=zohomail.com; s=zohoarc; b=deh1rEqJY3hshjbNsRwXFNYIqId6s0sTCD0Jk60mZWZIMMTH6EEt7IBjX3uD38tSV4xZ54QKDmS1mmwvL+1stfdDv7qKPDRGC1hK8sNCMofvbRM3SbXP5j/Z7YNaZGXjjzHam3wl7waIgMqQf89Vt+lYcJUrCgJtFAtRtKmlZpo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770520; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=E2/QSQpKB1Wxz1OwWrj4zfmK4ONtqzkfez0TTluzjsI=; b=cEFC7v6lnpfBhQaLxVurwBIhA+cCDQmgvlagEZI5z0DYQzU3kUJICdR/mPM9dR9Wk7hNiulU/HE7ALvI077FHz1JGuaHvtlXd6v2AZpbiqbwUKNSIV5e2bsl/2+EHakjP/JvDaTbcXRTgCf/e3BSX05C0SNx3hvKa0aTGYMBPKw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770520665586.2954425822298; Tue, 3 Jan 2023 10:28:40 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrj-0000Vj-MH; Tue, 03 Jan 2023 13:18:23 -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 1pClrc-0000Aw-53 for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:16 -0500 Received: from mail-vs1-xe30.google.com ([2607:f8b0:4864:20::e30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClra-0005Gi-D0 for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:15 -0500 Received: by mail-vs1-xe30.google.com with SMTP id i188so32588136vsi.8 for ; Tue, 03 Jan 2023 10:18:14 -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.18.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:18:13 -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=E2/QSQpKB1Wxz1OwWrj4zfmK4ONtqzkfez0TTluzjsI=; b=UQgK1skC3e4rFb4PCxuSHjLP8wiDvcqTC38RJMIDB9R/01AcJPJw7DfBdVqpCbsvD/ lywseIev8sJ1KXqKBkSoSp549UTWXDL/02YH6nzg64/MfhsBDYXthdzMovclf9o/OCdQ BpDCCG1ekKhSXAtZDZs8g9V2kgwA+B+G4iivVsEVQWrW0Xl7FWuzFbZuEWzLqePtMbOy qV5oD3tDy6FX+ZtPFqRHaXBss0Q+NzWwVZBHxhar6PTRbM9ECubwEL5wZ13mYWTHlyTv w9VBMIolcngD1ltRyu2j5dJIE59KoIglX9b3yxgV12uVmSfRxJQo7+eJAzeEbglC/jwM fJjA== 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=E2/QSQpKB1Wxz1OwWrj4zfmK4ONtqzkfez0TTluzjsI=; b=kWc/ZG/zbA0BACJd1A6mKxc2QlyXjbBInwaLkP8ng3h+L7fczMSvPjcgiHYsMRVz+D lK5khw0Zx9DkL7D6YHyNw8nDYVtGmxtLAzHjaRghdv+6iA6MGumGzIo9yTj5RDVFpt7s ISuwSTvMoxPcTkFWBz5pOfBmNx/3EEfXlQsc96vn2091zZxfeLmdpBNBDMC0T2JFi2sJ eziKOPJCaijgT9x59dQ8cQXzV19gUVBRv/qCN9xdTBJsIjXZd5UVbZmZWg4blHpwrdnI Ol2i6wSELkiWEn+rPoX/6wwI9k43kyKb8O+CGZAA9+6HMrrkUU17RFXvCsf4BmDR3lEG M2og== X-Gm-Message-State: AFqh2kqf5W3V74PZH7lmMtuQy5D8VVbz17LL6VZqcQeWBJ3xCOBlKfPx Ta+l0KE15H5vY6RszNN0sbBTS8yKoq9Zy7dcg4A= X-Google-Smtp-Source: AMrXdXtW8C9DLhWFhlG3kL7oCTQFTiCi22iccxXUJWwAIhdhlJDGUzwBIA4AX8GLuuwlbGx8tTIvLw== X-Received: by 2002:a05:6102:3e18:b0:3c5:ec9a:9348 with SMTP id j24-20020a0561023e1800b003c5ec9a9348mr18321561vsv.20.1672769893723; Tue, 03 Jan 2023 10:18:13 -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 28/40] target/arm: Split out xscale*_class_init Date: Tue, 3 Jan 2023 10:16:34 -0800 Message-Id: <20230103181646.55711-29-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::e30; envelope-from=richard.henderson@linaro.org; helo=mail-vs1-xe30.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770522240100001 Content-Type: text/plain; charset="utf-8" Use two intermediate functions to share code between the 13 variants of pxa*_class_init. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/cpu_tcg.c | 81 +++++++++++++------------------------------- 1 file changed, 23 insertions(+), 58 deletions(-) diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c index c6d50f326e..a3b6940040 100644 --- a/target/arm/cpu_tcg.c +++ b/target/arm/cpu_tcg.c @@ -857,120 +857,85 @@ static void sa1110_class_init(ARMCPUClass *acc) acc->midr =3D 0x6901B119; } =20 -static void pxa250_class_init(ARMCPUClass *acc) +static void xscale_class_init(ARMCPUClass *acc) { acc->dtb_compatible =3D "marvell,xscale"; set_class_feature(acc, ARM_FEATURE_V5); set_class_feature(acc, ARM_FEATURE_XSCALE); - acc->midr =3D 0x69052100; acc->ctr =3D 0xd172172; acc->reset_sctlr =3D 0x00000078; } =20 +static void pxa250_class_init(ARMCPUClass *acc) +{ + xscale_class_init(acc); + acc->midr =3D 0x69052100; +} + static void pxa255_class_init(ARMCPUClass *acc) { - acc->dtb_compatible =3D "marvell,xscale"; - set_class_feature(acc, ARM_FEATURE_V5); - set_class_feature(acc, ARM_FEATURE_XSCALE); + xscale_class_init(acc); acc->midr =3D 0x69052d00; - acc->ctr =3D 0xd172172; - acc->reset_sctlr =3D 0x00000078; } =20 static void pxa260_class_init(ARMCPUClass *acc) { - acc->dtb_compatible =3D "marvell,xscale"; - set_class_feature(acc, ARM_FEATURE_V5); - set_class_feature(acc, ARM_FEATURE_XSCALE); + xscale_class_init(acc); acc->midr =3D 0x69052903; - acc->ctr =3D 0xd172172; - acc->reset_sctlr =3D 0x00000078; } =20 static void pxa261_class_init(ARMCPUClass *acc) { - acc->dtb_compatible =3D "marvell,xscale"; - set_class_feature(acc, ARM_FEATURE_V5); - set_class_feature(acc, ARM_FEATURE_XSCALE); + xscale_class_init(acc); acc->midr =3D 0x69052d05; - acc->ctr =3D 0xd172172; - acc->reset_sctlr =3D 0x00000078; } =20 static void pxa262_class_init(ARMCPUClass *acc) { - acc->dtb_compatible =3D "marvell,xscale"; - set_class_feature(acc, ARM_FEATURE_V5); - set_class_feature(acc, ARM_FEATURE_XSCALE); + xscale_class_init(acc); acc->midr =3D 0x69052d06; - acc->ctr =3D 0xd172172; - acc->reset_sctlr =3D 0x00000078; +} + +static void xscale_iwmmxt_class_init(ARMCPUClass *acc) +{ + xscale_class_init(acc); + set_class_feature(acc, ARM_FEATURE_IWMMXT); } =20 static void pxa270a0_class_init(ARMCPUClass *acc) { - acc->dtb_compatible =3D "marvell,xscale"; - set_class_feature(acc, ARM_FEATURE_V5); - set_class_feature(acc, ARM_FEATURE_XSCALE); - set_class_feature(acc, ARM_FEATURE_IWMMXT); + xscale_iwmmxt_class_init(acc); acc->midr =3D 0x69054110; - acc->ctr =3D 0xd172172; - acc->reset_sctlr =3D 0x00000078; } =20 static void pxa270a1_class_init(ARMCPUClass *acc) { - acc->dtb_compatible =3D "marvell,xscale"; - set_class_feature(acc, ARM_FEATURE_V5); - set_class_feature(acc, ARM_FEATURE_XSCALE); - set_class_feature(acc, ARM_FEATURE_IWMMXT); + xscale_iwmmxt_class_init(acc); acc->midr =3D 0x69054111; - acc->ctr =3D 0xd172172; - acc->reset_sctlr =3D 0x00000078; } =20 static void pxa270b0_class_init(ARMCPUClass *acc) { - acc->dtb_compatible =3D "marvell,xscale"; - set_class_feature(acc, ARM_FEATURE_V5); - set_class_feature(acc, ARM_FEATURE_XSCALE); - set_class_feature(acc, ARM_FEATURE_IWMMXT); + xscale_iwmmxt_class_init(acc); acc->midr =3D 0x69054112; - acc->ctr =3D 0xd172172; - acc->reset_sctlr =3D 0x00000078; } =20 static void pxa270b1_class_init(ARMCPUClass *acc) { - acc->dtb_compatible =3D "marvell,xscale"; - set_class_feature(acc, ARM_FEATURE_V5); - set_class_feature(acc, ARM_FEATURE_XSCALE); - set_class_feature(acc, ARM_FEATURE_IWMMXT); + xscale_iwmmxt_class_init(acc); acc->midr =3D 0x69054113; - acc->ctr =3D 0xd172172; - acc->reset_sctlr =3D 0x00000078; } =20 static void pxa270c0_class_init(ARMCPUClass *acc) { - acc->dtb_compatible =3D "marvell,xscale"; - set_class_feature(acc, ARM_FEATURE_V5); - set_class_feature(acc, ARM_FEATURE_XSCALE); - set_class_feature(acc, ARM_FEATURE_IWMMXT); + xscale_iwmmxt_class_init(acc); acc->midr =3D 0x69054114; - acc->ctr =3D 0xd172172; - acc->reset_sctlr =3D 0x00000078; } =20 static void pxa270c5_class_init(ARMCPUClass *acc) { - acc->dtb_compatible =3D "marvell,xscale"; - set_class_feature(acc, ARM_FEATURE_V5); - set_class_feature(acc, ARM_FEATURE_XSCALE); - set_class_feature(acc, ARM_FEATURE_IWMMXT); + xscale_iwmmxt_class_init(acc); acc->midr =3D 0x69054117; - acc->ctr =3D 0xd172172; - acc->reset_sctlr =3D 0x00000078; } =20 #ifdef CONFIG_TCG --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770065; cv=none; d=zohomail.com; s=zohoarc; b=nHjcsFGpJBugaewTBO0KcpsPA0p5jrRYILFV0KzAvPRWk2KZM31CET/0YF0U14W7/QqWR1Fm1Zc7w+gS8dZSZ/nnfnt3Fo6paBNaYmOeCCAnLQmMfL62emRIplEgJj8uo90d0AVCpYCGtxb18ZtNXB4zw77gfMWgz5tk4kvQioQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770065; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dBH2/umBb6PUIXvvI6VS3ET+RrQOEaWp5m0MqQjwqxU=; b=efMU4vA2fKUTDaT+AFb5jFRFT3qMH9RPjYltakvukTzS4aouAY/jfO6sWeZjprWsPAHV/Q3F69HXfgZdoO41NgVnCXrBRjyP+U/ym2MlOARxmi2MPB8kC6NdQNedbkicWz9hrWPeZwNI5jpJiZH0jLcuYCmRWLU5IIFOW9f/xYw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770065667475.92269839880237; Tue, 3 Jan 2023 10:21:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrm-0000dX-3w; Tue, 03 Jan 2023 13:18:26 -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 1pClrg-0000Ma-Pu for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:20 -0500 Received: from mail-qt1-x82f.google.com ([2607:f8b0:4864:20::82f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClrd-0005Ln-N1 for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:20 -0500 Received: by mail-qt1-x82f.google.com with SMTP id v14so22398957qtq.3 for ; Tue, 03 Jan 2023 10:18:17 -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.18.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:18:16 -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=dBH2/umBb6PUIXvvI6VS3ET+RrQOEaWp5m0MqQjwqxU=; b=n/EpmBe8YZVoQauSUJmZprJIC2a1icTYbWavIhbs27arcEEFf1I7yKWA/We/3oyhMY 865AmGM6zhAoVgmSZVjfgRz2GRM4a8941m2wXSUJkX+prC6ZK/AMp59RKUtUUshSG8H2 pfVRjgHodz6UnRiBapUr5OALcn8smD/vDu4tnULsh1axJRSfLYryMloBo6DECs8uber2 99MIM2hzlQiLCuFZOEuNJ0VJ/+t8h6fy1FkD/xQsFm6eCqz/Xr3kIsd6CFzXA1HGdcdq YPzBBMvRsbbboNYZ/vcMwATcYo9fdO/5R4HwhlOP7xlhFEKnSOZrVK40qawIDoXQV84H TffQ== 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=dBH2/umBb6PUIXvvI6VS3ET+RrQOEaWp5m0MqQjwqxU=; b=LRwqNCttRku5wG5mFvHrJtKhsqcMFTu5ljQToylThl/ZTUgIOdYBnhXMfyOZQJSLz5 jlC9VhX9ScvjCZ6+ywneIaWTg+jiffYABGSzi3WCknfw5bk0dVlNR0nfAp2Hd9YP5OyO riFQRUPcPG6u0ZBsbn7sN0dSMXCpHBkhlGUFIIKzgVGEXMZTWzx/uxKdMBWmC+ULfuNM 9Dp0+WrHlqN2d3wr4AQx3G0H1+4sOXp8AokQnprDcrqyLlMXkfWgX+F1B3WhQaQ8PJNH COJTv5+vSA646BSUSvz494jQ77lsB8FEwd5fKBngIi3Ka1gHEZfb0plDzh8/tzyTfedU VKBA== X-Gm-Message-State: AFqh2kroC3CKOFKsLkDBKQiYxunxagRvNGwykdewJnR9/QvnWs+c6m3A OUrAW+eF4G/bWiTiyJtp8nhP0jP7H8+ZFjq+Fwg= X-Google-Smtp-Source: AMrXdXsIpsDFWVspYR0ifayqMc/qK9BwUtZbERMTPmWGIFrUqkqsVYw6tWPwZUkxsjo3eGg0B6aC7g== X-Received: by 2002:ac8:5207:0:b0:3a8:177a:665f with SMTP id r7-20020ac85207000000b003a8177a665fmr57422301qtn.50.1672769896583; Tue, 03 Jan 2023 10:18:16 -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 29/40] target/arm: Remove m-profile has_vfp and has_dsp properties Date: Tue, 3 Jan 2023 10:16:35 -0800 Message-Id: <20230103181646.55711-30-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82f; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82f.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770067198100003 Content-Type: text/plain; charset="utf-8" Replace the properties with separate cpu classes that have these features disabled. These stand in the way of moving all id-register properties to the cpu class level, because of the case of SSE200, which has one cortex-m33 with dsp+vfp and one without. Create the full set of m-profile cpus with and without the corresponding options. As per https://developer.arm.com/documentation/102787/0100 cortex m-{4,7,33,55} have a configurable fpu, while only cortex-m33 has a configurable dsp (we don't implement m35). The armv7m boards besides armsse will be able to use -cpu cortex-mX-nofpu instead of -cpu cortex-mX,has_fpu=3Doff. Signed-off-by: Richard Henderson --- include/hw/arm/armsse.h | 3 +- include/hw/arm/armv7m.h | 2 - target/arm/cpu.h | 2 - hw/arm/armsse.c | 53 +++++++++++++++------------ hw/arm/armv7m.c | 12 ------ hw/arm/musca.c | 14 +++---- target/arm/cpu.c | 30 +-------------- target/arm/cpu_tcg.c | 81 +++++++++++++++++++++++++++++++++++++++++ 8 files changed, 118 insertions(+), 79 deletions(-) diff --git a/include/hw/arm/armsse.h b/include/hw/arm/armsse.h index 9648e7a419..98e371c83c 100644 --- a/include/hw/arm/armsse.h +++ b/include/hw/arm/armsse.h @@ -123,6 +123,7 @@ OBJECT_DECLARE_TYPE(ARMSSE, ARMSSEClass, */ #define TYPE_IOTKIT "iotkit" #define TYPE_SSE200 "sse-200" +#define TYPE_SSE200_B "sse-200-b" #define TYPE_SSE300 "sse-300" =20 /* We have an IRQ splitter and an OR gate input for each external PPC @@ -221,8 +222,6 @@ struct ARMSSE { uint32_t exp_numirq; uint32_t sram_addr_width; uint32_t init_svtor; - bool cpu_fpu[SSE_MAX_CPUS]; - bool cpu_dsp[SSE_MAX_CPUS]; }; =20 typedef struct ARMSSEInfo ARMSSEInfo; diff --git a/include/hw/arm/armv7m.h b/include/hw/arm/armv7m.h index b7ba0ff409..a24433172c 100644 --- a/include/hw/arm/armv7m.h +++ b/include/hw/arm/armv7m.h @@ -97,8 +97,6 @@ struct ARMv7MState { uint32_t init_nsvtor; bool enable_bitband; bool start_powered_off; - bool vfp; - bool dsp; }; =20 #endif diff --git a/target/arm/cpu.h b/target/arm/cpu.h index e8dd75b003..4b47a420d5 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -897,8 +897,6 @@ struct ArchCPU { bool has_vfp; /* CPU has Neon */ bool has_neon; - /* CPU has M-profile DSP extension */ - bool has_dsp; =20 /* CPU has memory protection unit */ bool has_mpu; diff --git a/hw/arm/armsse.c b/hw/arm/armsse.c index 0202bad787..9d6280eec5 100644 --- a/hw/arm/armsse.c +++ b/hw/arm/armsse.c @@ -57,7 +57,7 @@ typedef struct ARMSSEDeviceInfo { =20 struct ARMSSEInfo { const char *name; - const char *cpu_type; + const char *cpu_type[SSE_MAX_CPUS]; uint32_t sse_version; int sram_banks; uint32_t sram_bank_base; @@ -83,8 +83,6 @@ static Property iotkit_properties[] =3D { DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64), DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15), DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), - DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true), - DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], true), DEFINE_PROP_END_OF_LIST() }; =20 @@ -94,10 +92,6 @@ static Property sse200_properties[] =3D { DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64), DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 15), DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), - DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], false), - DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], false), - DEFINE_PROP_BOOL("CPU1_FPU", ARMSSE, cpu_fpu[1], true), - DEFINE_PROP_BOOL("CPU1_DSP", ARMSSE, cpu_dsp[1], true), DEFINE_PROP_END_OF_LIST() }; =20 @@ -107,8 +101,6 @@ static Property sse300_properties[] =3D { DEFINE_PROP_UINT32("EXP_NUMIRQ", ARMSSE, exp_numirq, 64), DEFINE_PROP_UINT32("SRAM_ADDR_WIDTH", ARMSSE, sram_addr_width, 18), DEFINE_PROP_UINT32("init-svtor", ARMSSE, init_svtor, 0x10000000), - DEFINE_PROP_BOOL("CPU0_FPU", ARMSSE, cpu_fpu[0], true), - DEFINE_PROP_BOOL("CPU0_DSP", ARMSSE, cpu_dsp[0], true), DEFINE_PROP_END_OF_LIST() }; =20 @@ -505,7 +497,7 @@ static const ARMSSEInfo armsse_variants[] =3D { { .name =3D TYPE_IOTKIT, .sse_version =3D ARMSSE_IOTKIT, - .cpu_type =3D ARM_CPU_TYPE_NAME("cortex-m33"), + .cpu_type[0] =3D ARM_CPU_TYPE_NAME("cortex-m33"), .sram_banks =3D 1, .sram_bank_base =3D 0x20000000, .num_cpus =3D 1, @@ -526,7 +518,31 @@ static const ARMSSEInfo armsse_variants[] =3D { { .name =3D TYPE_SSE200, .sse_version =3D ARMSSE_SSE200, - .cpu_type =3D ARM_CPU_TYPE_NAME("cortex-m33"), + .cpu_type[0] =3D ARM_CPU_TYPE_NAME("cortex-m33-nodsp-novfp"), + .cpu_type[1] =3D ARM_CPU_TYPE_NAME("cortex-m33"), + .sram_banks =3D 4, + .sram_bank_base =3D 0x20000000, + .num_cpus =3D 2, + .sys_version =3D 0x22041743, + .iidr =3D 0, + .cpuwait_rst =3D 2, + .has_mhus =3D true, + .has_cachectrl =3D true, + .has_cpusecctrl =3D true, + .has_cpuid =3D true, + .has_cpu_pwrctrl =3D false, + .has_sse_counter =3D false, + .has_tcms =3D false, + .props =3D sse200_properties, + .devinfo =3D sse200_devices, + .irq_is_common =3D sse200_irq_is_common, + }, + { + /* For Musca-B1, differs only on cpu[0]. */ + .name =3D TYPE_SSE200_B, + .sse_version =3D ARMSSE_SSE200, + .cpu_type[0] =3D ARM_CPU_TYPE_NAME("cortex-m33"), + .cpu_type[1] =3D ARM_CPU_TYPE_NAME("cortex-m33"), .sram_banks =3D 4, .sram_bank_base =3D 0x20000000, .num_cpus =3D 2, @@ -547,7 +563,7 @@ static const ARMSSEInfo armsse_variants[] =3D { { .name =3D TYPE_SSE300, .sse_version =3D ARMSSE_SSE300, - .cpu_type =3D ARM_CPU_TYPE_NAME("cortex-m55"), + .cpu_type[0] =3D ARM_CPU_TYPE_NAME("cortex-m55"), .sram_banks =3D 2, .sram_bank_base =3D 0x21000000, .num_cpus =3D 1, @@ -720,7 +736,8 @@ static void armsse_init(Object *obj) name =3D g_strdup_printf("armv7m%d", i); object_initialize_child(OBJECT(&s->cluster[i]), name, &s->armv7m[i= ], TYPE_ARMV7M); - qdev_prop_set_string(DEVICE(&s->armv7m[i]), "cpu-type", info->cpu_= type); + qdev_prop_set_string(DEVICE(&s->armv7m[i]), "cpu-type", + info->cpu_type[i]); g_free(name); name =3D g_strdup_printf("arm-sse-cpu-container%d", i); memory_region_init(&s->cpu_container[i], obj, name, UINT64_MAX); @@ -1019,16 +1036,6 @@ static void armsse_realize(DeviceState *dev, Error *= *errp) return; } } - if (!s->cpu_fpu[i]) { - if (!object_property_set_bool(cpuobj, "vfp", false, errp)) { - return; - } - } - if (!s->cpu_dsp[i]) { - if (!object_property_set_bool(cpuobj, "dsp", false, errp)) { - return; - } - } =20 if (i > 0) { memory_region_add_subregion_overlap(&s->cpu_container[i], 0, diff --git a/hw/arm/armv7m.c b/hw/arm/armv7m.c index 50a9507c0b..fdd1c77c08 100644 --- a/hw/arm/armv7m.c +++ b/hw/arm/armv7m.c @@ -323,16 +323,6 @@ static void armv7m_realize(DeviceState *dev, Error **e= rrp) return; } } - if (object_property_find(OBJECT(s->cpu), "vfp")) { - if (!object_property_set_bool(OBJECT(s->cpu), "vfp", s->vfp, errp)= ) { - return; - } - } - if (object_property_find(OBJECT(s->cpu), "dsp")) { - if (!object_property_set_bool(OBJECT(s->cpu), "dsp", s->dsp, errp)= ) { - return; - } - } =20 /* * Tell the CPU where the NVIC is; it will fail realize if it doesn't @@ -528,8 +518,6 @@ static Property armv7m_properties[] =3D { DEFINE_PROP_BOOL("enable-bitband", ARMv7MState, enable_bitband, false), DEFINE_PROP_BOOL("start-powered-off", ARMv7MState, start_powered_off, false), - DEFINE_PROP_BOOL("vfp", ARMv7MState, vfp, true), - DEFINE_PROP_BOOL("dsp", ARMv7MState, dsp, true), DEFINE_PROP_END_OF_LIST(), }; =20 diff --git a/hw/arm/musca.c b/hw/arm/musca.c index 6eeee57c9d..1cb76ba2a9 100644 --- a/hw/arm/musca.c +++ b/hw/arm/musca.c @@ -377,8 +377,12 @@ static void musca_init(MachineState *machine) mms->s32kclk =3D clock_new(OBJECT(machine), "S32KCLK"); clock_set_hz(mms->s32kclk, S32KCLK_FRQ); =20 + /* + * Musca-A takes the default SSE-200 FPU/DSP settings (ie no for + * CPU0 and yes for CPU1); Musca-B1 explicitly enables them for CPU0. + */ object_initialize_child(OBJECT(machine), "sse-200", &mms->sse, - TYPE_SSE200); + mmc->type =3D=3D MUSCA_A ? TYPE_SSE200 : TYPE_= SSE200_B); ssedev =3D DEVICE(&mms->sse); object_property_set_link(OBJECT(&mms->sse), "memory", OBJECT(system_memory), &error_fatal); @@ -387,14 +391,6 @@ static void musca_init(MachineState *machine) qdev_prop_set_uint32(ssedev, "SRAM_ADDR_WIDTH", mmc->sram_addr_width); qdev_connect_clock_in(ssedev, "MAINCLK", mms->sysclk); qdev_connect_clock_in(ssedev, "S32KCLK", mms->s32kclk); - /* - * Musca-A takes the default SSE-200 FPU/DSP settings (ie no for - * CPU0 and yes for CPU1); Musca-B1 explicitly enables them for CPU0. - */ - if (mmc->type =3D=3D MUSCA_B1) { - qdev_prop_set_bit(ssedev, "CPU0_FPU", true); - qdev_prop_set_bit(ssedev, "CPU0_DSP", true); - } sysbus_realize(SYS_BUS_DEVICE(&mms->sse), &error_fatal); =20 /* diff --git a/target/arm/cpu.c b/target/arm/cpu.c index f4d8be6c4c..0824af601f 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1305,9 +1305,6 @@ static Property arm_cpu_has_vfp_property =3D static Property arm_cpu_has_neon_property =3D DEFINE_PROP_BOOL("neon", ARMCPU, has_neon, true); =20 -static Property arm_cpu_has_dsp_property =3D - DEFINE_PROP_BOOL("dsp", ARMCPU, has_dsp, true); - static Property arm_cpu_has_mpu_property =3D DEFINE_PROP_BOOL("has-mpu", ARMCPU, has_mpu, true); =20 @@ -1428,7 +1425,7 @@ static void arm_cpu_post_init(Object *obj) ? cpu_isar_feature(aa64_fp_simd, cpu) : cpu_isar_feature(aa32_vfp, cpu)) { cpu->has_vfp =3D true; - if (!kvm_enabled()) { + if (!kvm_enabled() && !arm_feature(&cpu->env, ARM_FEATURE_M)) { qdev_property_add_static(DEVICE(obj), &arm_cpu_has_vfp_propert= y); } } @@ -1440,11 +1437,6 @@ static void arm_cpu_post_init(Object *obj) } } =20 - if (arm_feature(&cpu->env, ARM_FEATURE_M) && - arm_feature(&cpu->env, ARM_FEATURE_THUMB_DSP)) { - qdev_property_add_static(DEVICE(obj), &arm_cpu_has_dsp_property); - } - if (arm_feature(&cpu->env, ARM_FEATURE_PMSA)) { qdev_property_add_static(DEVICE(obj), &arm_cpu_has_mpu_property); if (arm_feature(&cpu->env, ARM_FEATURE_V7)) { @@ -1801,26 +1793,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Erro= r **errp) cpu->isar.mvfr1 =3D u; } =20 - if (arm_feature(env, ARM_FEATURE_M) && !cpu->has_dsp) { - uint32_t u; - - unset_feature(env, ARM_FEATURE_THUMB_DSP); - - u =3D cpu->isar.id_isar1; - u =3D FIELD_DP32(u, ID_ISAR1, EXTEND, 1); - cpu->isar.id_isar1 =3D u; - - u =3D cpu->isar.id_isar2; - u =3D FIELD_DP32(u, ID_ISAR2, MULTU, 1); - u =3D FIELD_DP32(u, ID_ISAR2, MULTS, 1); - cpu->isar.id_isar2 =3D u; - - u =3D cpu->isar.id_isar3; - u =3D FIELD_DP32(u, ID_ISAR3, SIMD, 1); - u =3D FIELD_DP32(u, ID_ISAR3, SATURATE, 0); - cpu->isar.id_isar3 =3D u; - } - /* Some features automatically imply others: */ if (arm_feature(env, ARM_FEATURE_V8)) { if (arm_feature(env, ARM_FEATURE_M)) { diff --git a/target/arm/cpu_tcg.c b/target/arm/cpu_tcg.c index a3b6940040..2292597c3c 100644 --- a/target/arm/cpu_tcg.c +++ b/target/arm/cpu_tcg.c @@ -661,6 +661,34 @@ static void cortex_m3_class_init(ARMCPUClass *acc) acc->isar.id_isar6 =3D 0x00000000; } =20 +static void disable_m_dsp(ARMCPUClass *acc) +{ + uint32_t u; + + u =3D acc->isar.id_isar1; + u =3D FIELD_DP32(u, ID_ISAR1, EXTEND, 1); + acc->isar.id_isar1 =3D u; + + u =3D acc->isar.id_isar2; + u =3D FIELD_DP32(u, ID_ISAR2, MULTU, 1); + u =3D FIELD_DP32(u, ID_ISAR2, MULTS, 1); + acc->isar.id_isar2 =3D u; + + u =3D acc->isar.id_isar3; + u =3D FIELD_DP32(u, ID_ISAR3, SIMD, 1); + u =3D FIELD_DP32(u, ID_ISAR3, SATURATE, 0); + acc->isar.id_isar3 =3D u; + + unset_class_feature(acc, ARM_FEATURE_THUMB_DSP); +} + +static void disable_m_vfp(ARMCPUClass *acc) +{ + acc->isar.mvfr0 =3D 0; + acc->isar.mvfr1 =3D 0; + acc->isar.mvfr2 =3D 0; +} + static void cortex_m4_class_init(ARMCPUClass *acc) { set_class_feature(acc, ARM_FEATURE_V7); @@ -689,6 +717,12 @@ static void cortex_m4_class_init(ARMCPUClass *acc) acc->isar.id_isar6 =3D 0x00000000; } =20 +static void cortex_m4_nf_class_init(ARMCPUClass *acc) +{ + cortex_m4_class_init(acc); + disable_m_vfp(acc); +} + static void cortex_m7_class_init(ARMCPUClass *acc) { set_class_feature(acc, ARM_FEATURE_V7); @@ -717,6 +751,12 @@ static void cortex_m7_class_init(ARMCPUClass *acc) acc->isar.id_isar6 =3D 0x00000000; } =20 +static void cortex_m7_nf_class_init(ARMCPUClass *acc) +{ + cortex_m7_class_init(acc); + disable_m_vfp(acc); +} + static void cortex_m33_class_init(ARMCPUClass *acc) { set_class_feature(acc, ARM_FEATURE_V8); @@ -749,6 +789,25 @@ static void cortex_m33_class_init(ARMCPUClass *acc) acc->ctr =3D 0x8000c000; } =20 +static void cortex_m33_nd_class_init(ARMCPUClass *acc) +{ + cortex_m33_class_init(acc); + disable_m_dsp(acc); +} + +static void cortex_m33_nf_class_init(ARMCPUClass *acc) +{ + cortex_m33_class_init(acc); + disable_m_vfp(acc); +} + +static void cortex_m33_ndnf_class_init(ARMCPUClass *acc) +{ + cortex_m33_class_init(acc); + disable_m_dsp(acc); + disable_m_vfp(acc); +} + static void cortex_m55_class_init(ARMCPUClass *acc) { set_class_feature(acc, ARM_FEATURE_V8); @@ -784,6 +843,12 @@ static void cortex_m55_class_init(ARMCPUClass *acc) acc->ctr =3D 0x8303c003; } =20 +static void cortex_m55_nf_class_init(ARMCPUClass *acc) +{ + cortex_m55_class_init(acc); + disable_m_vfp(acc); +} + static const ARMCPRegInfo cortexr5_cp_reginfo[] =3D { /* Dummy the TCM region regs for the moment */ { .name =3D "ATCM", .cp =3D 15, .opc1 =3D 0, .crn =3D 9, .crm =3D 1, .= opc2 =3D 0, @@ -1081,10 +1146,26 @@ static const ARMCPUInfo arm_tcg_cpus[] =3D { static const ARMCPUInfo arm_v7m_tcg_cpus[] =3D { { .name =3D "cortex-m0", .class_init =3D cortex_m0_class_init }, { .name =3D "cortex-m3", .class_init =3D cortex_m3_class_init }, + { .name =3D "cortex-m4", .class_init =3D cortex_m4_class_init }, + { .name =3D "cortex-m4-novfp", + .class_init =3D cortex_m4_nf_class_init }, + { .name =3D "cortex-m7", .class_init =3D cortex_m7_class_init }, + { .name =3D "cortex-m7-novfp", + .class_init =3D cortex_m7_nf_class_init }, + { .name =3D "cortex-m33", .class_init =3D cortex_m33_class_init }, + { .name =3D "cortex-m33-nodsp", + .class_init =3D cortex_m33_nd_class_init }, + { .name =3D "cortex-m33-novfp", + .class_init =3D cortex_m33_nf_class_init }, + { .name =3D "cortex-m33-nodsp-novfp", + .class_init =3D cortex_m33_ndnf_class_init }, + { .name =3D "cortex-m55", .class_init =3D cortex_m55_class_init }, + { .name =3D "cortex-m55-novfp", + .class_init =3D cortex_m55_nf_class_init }, }; =20 static const TypeInfo arm_v7m_cpu_type_info =3D { --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770288; cv=none; d=zohomail.com; s=zohoarc; b=cG3yUPBnZNG0o6e1ddXIIc8Nx/WVGfLVb3NXoppaaorGGPps0gFSxVRBkYasSkulUmRaWQ2blS/cAfF6h6myPFsjzlI/KuM6+MsJGwpQyl2//6Uwha2acC85lK410A1yl23R5soDCTEwnysgASrHStt7zpolwLWkXH35eaYnyuY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770288; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=dszATuIwttfYWieXQT1KqRjch1JsKTu3HotiKgzPAys=; b=eMoS7otDsBYwXanBkRQcFGlhsm7OkOraXsMcVxpCXrqT0omKjRPxYeIvBLne0QReQJYuRYi1QWSkhzbRzb6dTnmwFoa/SNRdry5lOuqhy7vxvrfJ1ObQThfLXrHRpipSLKZsqYpDGO7XgDk/9oCPO4dmCOX7dt38K0KaFDRWgu8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 16727702884517.489818893368124; Tue, 3 Jan 2023 10:24:48 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrl-0000dH-CW; Tue, 03 Jan 2023 13:18:26 -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 1pClri-0000T4-Bz for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:22 -0500 Received: from mail-qv1-xf2d.google.com ([2607:f8b0:4864:20::f2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClrg-0005M8-FS for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:22 -0500 Received: by mail-qv1-xf2d.google.com with SMTP id df17so18377971qvb.3 for ; Tue, 03 Jan 2023 10:18:20 -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.18.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:18:19 -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=dszATuIwttfYWieXQT1KqRjch1JsKTu3HotiKgzPAys=; b=T5+n9k2FQJzUZULUbO95btcHJVlelh3ru58N3xgxXMV/N+unjgy/1B1cRgFvPbVLJe 1lG02X/xSvaO2QIa1QYLAeInrLmeTUh0EQHPlY2X7psLLlZTAgTDTqgWaKPWF9FvoVy/ nO3aAFvimz6qMbdjPJikZfVp6QT0IrLen/xIkSC1Kdl0Pd7rejlnyuXv5UQm7QCgfUUh 8FJdroUULUvWDWY9LpjsDphgGc+hLy43SbzsBb7vp7cc5DEd7ip6k23PR6g6Scit3u7Q P0+dQzQ05XzppQNVKuKIGYZaE4djd1I+EyVigQMUJfiL04gi2Y2Y9UTFDJSb7gK/3/du /OVg== 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=dszATuIwttfYWieXQT1KqRjch1JsKTu3HotiKgzPAys=; b=Q3ou1MXQjOZoltSmumliMK+Ldcvt6AjMePzSRiHEqvPOl/9DmJYvwkzHnTWPFfuhIv MEtOFnhCm6P9eb5j/HS1BXBcogA3s3JecdUIsiqE8u9c2ctqt6Qr1u8FMv/lqLj1Vtqp mTy7Tvc/CJEauMbhXROwpCrRW3NeBrkNmgjFrb9VshQJ/rY0KhkfI4JUpVuU4csBkqaK Vv7LPLmwpfz0wUUoVlHNEE0QVqc9q2qSQk/Ca9uyy88YXYFUaMMwIULUbvTd3YLQkfS/ TtwQqxz7H361v2KXRgZ8MgXXaMQFvwPuzaPa+BL/OcH1IPCuugHEGz5MdSELOQvF42VB IQvg== X-Gm-Message-State: AFqh2krsj98taPgfcp7dXTNqVjrbNjdAIGjhqqWXNQVhlpAFS118Ldew Z6SDZWw/gSDmY6IJOCBmQKmq9vzKziV0W7VXbQw= X-Google-Smtp-Source: AMrXdXt/wJli+wjdL9n3n3PAqNiLX5Gyy4VLyaFLh3OKOHK/M98qyOWJF+J69hYkJ3fnGfjtDSqOzQ== X-Received: by 2002:a0c:db8a:0:b0:531:dd54:9ad5 with SMTP id m10-20020a0cdb8a000000b00531dd549ad5mr2425204qvk.0.1672769899423; Tue, 03 Jan 2023 10:18:19 -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 30/40] target/arm: Move feature bit propagation to class init Date: Tue, 3 Jan 2023 10:16:36 -0800 Message-Id: <20230103181646.55711-31-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::f2d; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf2d.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770288831100002 Content-Type: text/plain; charset="utf-8" With the introduction of aarch64_host_class_init, we have enough feature bits set to do propagation early. Move the tcg consistency checks to class_late_init, after we have populated all of the id registers. Signed-off-by: Richard Henderson --- target/arm/cpu.c | 162 ++++++++++++++++++++++------------------------- 1 file changed, 77 insertions(+), 85 deletions(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 0824af601f..22a6ccaece 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1369,14 +1369,6 @@ static void arm_cpu_post_init(Object *obj) { ARMCPU *cpu =3D ARM_CPU(obj); =20 - /* M profile implies PMSA. We have to do this here rather than - * in realize with the other feature-implication checks because - * we look at the PMSA bit to see if we should add some properties. - */ - if (arm_feature(&cpu->env, ARM_FEATURE_M)) { - set_feature(&cpu->env, ARM_FEATURE_PMSA); - } - if (arm_feature(&cpu->env, ARM_FEATURE_CBAR) || arm_feature(&cpu->env, ARM_FEATURE_CBAR_RO)) { qdev_property_add_static(DEVICE(obj), &arm_cpu_reset_cbar_property= ); @@ -1574,7 +1566,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Error= **errp) CPUARMState *env =3D &cpu->env; int pagebits; Error *local_err =3D NULL; - bool no_aa32 =3D false; =20 #ifndef CONFIG_USER_ONLY /* The NVIC and M-profile CPU are two halves of a single piece of @@ -1793,82 +1784,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Erro= r **errp) cpu->isar.mvfr1 =3D u; } =20 - /* Some features automatically imply others: */ - if (arm_feature(env, ARM_FEATURE_V8)) { - if (arm_feature(env, ARM_FEATURE_M)) { - set_feature(env, ARM_FEATURE_V7); - } else { - set_feature(env, ARM_FEATURE_V7VE); - } - } - - /* - * There exist AArch64 cpus without AArch32 support. When KVM - * queries ID_ISAR0_EL1 on such a host, the value is UNKNOWN. - * Similarly, we cannot check ID_AA64PFR0 without AArch64 support. - * As a general principle, we also do not make ID register - * consistency checks anywhere unless using TCG, because only - * for TCG would a consistency-check failure be a QEMU bug. - */ - if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { - no_aa32 =3D !cpu_isar_feature(aa64_aa32, cpu); - } - - if (arm_feature(env, ARM_FEATURE_V7VE)) { - /* v7 Virtualization Extensions. In real hardware this implies - * EL2 and also the presence of the Security Extensions. - * For QEMU, for backwards-compatibility we implement some - * CPUs or CPU configs which have no actual EL2 or EL3 but do - * include the various other features that V7VE implies. - * Presence of EL2 itself is ARM_FEATURE_EL2, and of the - * Security Extensions is ARM_FEATURE_EL3. - */ - assert(!tcg_enabled() || no_aa32 || - cpu_isar_feature(aa32_arm_div, cpu)); - set_feature(env, ARM_FEATURE_LPAE); - set_feature(env, ARM_FEATURE_V7); - } - if (arm_feature(env, ARM_FEATURE_V7)) { - set_feature(env, ARM_FEATURE_VAPA); - set_feature(env, ARM_FEATURE_THUMB2); - set_feature(env, ARM_FEATURE_MPIDR); - if (!arm_feature(env, ARM_FEATURE_M)) { - set_feature(env, ARM_FEATURE_V6K); - } else { - set_feature(env, ARM_FEATURE_V6); - } - - /* Always define VBAR for V7 CPUs even if it doesn't exist in - * non-EL3 configs. This is needed by some legacy boards. - */ - set_feature(env, ARM_FEATURE_VBAR); - } - if (arm_feature(env, ARM_FEATURE_V6K)) { - set_feature(env, ARM_FEATURE_V6); - set_feature(env, ARM_FEATURE_MVFR); - } - if (arm_feature(env, ARM_FEATURE_V6)) { - set_feature(env, ARM_FEATURE_V5); - if (!arm_feature(env, ARM_FEATURE_M)) { - assert(!tcg_enabled() || no_aa32 || - cpu_isar_feature(aa32_jazelle, cpu)); - set_feature(env, ARM_FEATURE_AUXCR); - } - } - if (arm_feature(env, ARM_FEATURE_V5)) { - set_feature(env, ARM_FEATURE_V4T); - } - if (arm_feature(env, ARM_FEATURE_LPAE)) { - set_feature(env, ARM_FEATURE_V7MP); - } - if (arm_feature(env, ARM_FEATURE_CBAR_RO)) { - set_feature(env, ARM_FEATURE_CBAR); - } - if (arm_feature(env, ARM_FEATURE_THUMB2) && - !arm_feature(env, ARM_FEATURE_M)) { - set_feature(env, ARM_FEATURE_THUMB_DSP); - } - /* * We rely on no XScale CPU having VFP so we can use the same bits in = the * TB flags field for VECSTRIDE and XSCALE_CPAR. @@ -2318,6 +2233,67 @@ static void arm_cpu_leaf_class_init(ObjectClass *oc,= void *data) if (acc->info->class_init) { acc->info->class_init(acc); } + + /* Some features automatically imply others: */ + if (arm_class_feature(acc, ARM_FEATURE_V8)) { + if (arm_class_feature(acc, ARM_FEATURE_M)) { + set_class_feature(acc, ARM_FEATURE_V7); + } else { + set_class_feature(acc, ARM_FEATURE_V7VE); + } + } + if (arm_class_feature(acc, ARM_FEATURE_V7VE)) { + /* + * v7 Virtualization Extensions. In real hardware this implies + * EL2 and also the presence of the Security Extensions. + * For QEMU, for backwards-compatibility we implement some + * CPUs or CPU configs which have no actual EL2 or EL3 but do + * include the various other features that V7VE implies. + */ + set_class_feature(acc, ARM_FEATURE_LPAE); + set_class_feature(acc, ARM_FEATURE_V7); + } + if (arm_class_feature(acc, ARM_FEATURE_V7)) { + set_class_feature(acc, ARM_FEATURE_VAPA); + set_class_feature(acc, ARM_FEATURE_THUMB2); + set_class_feature(acc, ARM_FEATURE_MPIDR); + if (!arm_class_feature(acc, ARM_FEATURE_M)) { + set_class_feature(acc, ARM_FEATURE_V6K); + } else { + set_class_feature(acc, ARM_FEATURE_V6); + } + /* + * Always define VBAR for V7 CPUs even if it doesn't exist in + * non-EL3 configs. This is needed by some legacy boards. + */ + set_class_feature(acc, ARM_FEATURE_VBAR); + } + if (arm_class_feature(acc, ARM_FEATURE_V6K)) { + set_class_feature(acc, ARM_FEATURE_V6); + set_class_feature(acc, ARM_FEATURE_MVFR); + } + if (arm_class_feature(acc, ARM_FEATURE_V6)) { + set_class_feature(acc, ARM_FEATURE_V5); + if (!arm_class_feature(acc, ARM_FEATURE_M)) { + set_class_feature(acc, ARM_FEATURE_AUXCR); + } + } + if (arm_class_feature(acc, ARM_FEATURE_V5)) { + set_class_feature(acc, ARM_FEATURE_V4T); + } + if (arm_class_feature(acc, ARM_FEATURE_LPAE)) { + set_class_feature(acc, ARM_FEATURE_V7MP); + } + if (arm_class_feature(acc, ARM_FEATURE_CBAR_RO)) { + set_class_feature(acc, ARM_FEATURE_CBAR); + } + if (arm_class_feature(acc, ARM_FEATURE_THUMB2) && + !arm_class_feature(acc, ARM_FEATURE_M)) { + set_class_feature(acc, ARM_FEATURE_THUMB_DSP); + } + if (arm_class_feature(acc, ARM_FEATURE_M)) { + set_class_feature(acc, ARM_FEATURE_PMSA); + } } =20 static bool arm_cpu_class_late_init(ObjectClass *oc, Error **errp) @@ -2329,6 +2305,22 @@ static bool arm_cpu_class_late_init(ObjectClass *oc,= Error **errp) return false; } } + + /* Run some consistency checks for TCG. */ + if (tcg_enabled()) { + bool no_aa32 =3D arm_class_feature(acc, ARM_FEATURE_AARCH64) && + !class_isar_feature(aa64_aa32, acc); + + if (!no_aa32) { + if (arm_class_feature(acc, ARM_FEATURE_V7VE)) { + assert(class_isar_feature(aa32_arm_div, acc)); + } + if (arm_class_feature(acc, ARM_FEATURE_V6) && + !arm_class_feature(acc, ARM_FEATURE_M)) { + assert(class_isar_feature(aa32_jazelle, acc)); + } + } + } return true; } =20 --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672769994; cv=none; d=zohomail.com; s=zohoarc; b=X0E1wksg+zemq3d0c3Rmqt92EclxFyJ4o+ykoRFrPv+VAES1j09OqBFqo59nZD215TvgEOj2szIjlFo9Hg0hsfU439RzF2/OTpo/mYs3YmJ5/bgavh1duwboFVgQxLZZgWMr8lbGTODXQoHTpCLv9sqAAMkW+vgOFxTEshkegbA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672769994; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=0vUlG5Ud9gfVE8ISNFj2vMxvaEfoXG4adPrIDOgAWpM=; b=RsWKSqYPOrB0UkoNHRp1kQkEWNuHSrkWD6ye168Vb4JgfPLL3+B91tHRhlZMx+JoeqFF20+dzyDAmZO1u2Eud2iY+erNzYcn4oxQ9GTrVkl+Ld4PZum7LJCFXQTNlGwQMPaaF3Y+uCepz6xN0WymCjRi9rDdbqge945J35GIQis= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167276999464546.89709358315656; Tue, 3 Jan 2023 10:19:54 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrn-0000h9-MN; Tue, 03 Jan 2023 13:18:27 -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 1pClrk-0000cJ-Ua for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:24 -0500 Received: from mail-qt1-x829.google.com ([2607:f8b0:4864:20::829]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClrj-0005Me-BL for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:24 -0500 Received: by mail-qt1-x829.google.com with SMTP id j16so25184737qtv.4 for ; Tue, 03 Jan 2023 10:18:22 -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.18.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:18:21 -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=0vUlG5Ud9gfVE8ISNFj2vMxvaEfoXG4adPrIDOgAWpM=; b=Qb5JqUdO+0jgMkLu9NdZScsS6ukOhvJm5ypSYKijz+bPpBayRdDJl0XwKuoOVSTueu d73jeLtqc/jJSfGsNzrPZrr2SuBbBvHske3nycV/SkHxjGUAxZNWGtubj6RoXMHob/yT kQAE4oOHyMg97ROv627d7yAde/PVliFZzOKBXVQZ6w7dC4KMr1UjcA3OO7B4fzKZZunD NPOrWr9df7Pt+hjnDBF67q6BLIjJO/RYdVUJ6/HqdmapACLX/+E/wm3wXrwg6thQB0vM UDi6yOqitKpMF3kr7u7ocBMo/Yx6z8E4ysb/y73l5UZ9+CI+INJ7xvmlv61FWkMDZHUN Trsg== 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=0vUlG5Ud9gfVE8ISNFj2vMxvaEfoXG4adPrIDOgAWpM=; b=3L6+ezkGp7uCJTjTObyc+ThwCi+fs/kURrsOIXdQ35BLwkehRplmwZ2UBgPNFt2lJX xdqUGsCn08Hz+XAfXOrc28KTq7Y8eD9jbH4Q1/xRztFfAZTbNDmHPwTE/klKjOvLPCLi UivohRBWzPe/Ou+rO2Gk1Q2ynoUf1lc+X37GR1/EIpGqSZV5XHWhT2i95tF0xjO9Z/Xg snTZk44k2cgaLwZ03CkbLc0hPs0EDcdr0Us+8l8dXK9w4k8FuefNkBrystRaoUA/p5Ub wg/SiOvg8WerWfvH1XZrq80u6BFTLEMvZ/mXBM18r9wCOV176ESlJ9rOLZcpPcQ3VwRn haig== X-Gm-Message-State: AFqh2kowWBK6uGwDORpl6nI0xD10Bzm4Z3gsPZ/6RcpMZEyg/z8kTMEK 2/hjj6qJ0cAWiVo9wlDMs31YMLEuSuPAIYJgzqY= X-Google-Smtp-Source: AMrXdXvV04Ohi5xCz50YrUB0KO45/7utpaFCkVtmQLFy93b0QmNrfkpex1amBhhvnmLeE9NkdEgrmA== X-Received: by 2002:ac8:7513:0:b0:3a8:2e90:f7d4 with SMTP id u19-20020ac87513000000b003a82e90f7d4mr64999218qtq.27.1672769902261; Tue, 03 Jan 2023 10:18:22 -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 31/40] target/arm: Get and set class properties in the monitor Date: Tue, 3 Jan 2023 10:16:37 -0800 Message-Id: <20230103181646.55711-32-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::829; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x829.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672769996818100003 Content-Type: text/plain; charset="utf-8" Setting is not actually functional here, because it is always done after the creation of the first object, and so will generate an error. But at least it's a different error than 'Property not found'. Signed-off-by: Richard Henderson --- target/arm/monitor.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/target/arm/monitor.c b/target/arm/monitor.c index ecdd5ee817..262785e713 100644 --- a/target/arm/monitor.c +++ b/target/arm/monitor.c @@ -89,7 +89,7 @@ QEMU_BUILD_BUG_ON(ARM_MAX_VQ > 16); * will attempt to set them. If there are dependencies between features, * then the order that considers those dependencies must be used. */ -static const char *cpu_model_advertised_features[] =3D { +static const char * const cpu_model_advertised_features[] =3D { "aarch64", "pmu", "sve", "sve128", "sve256", "sve384", "sve512", "sve640", "sve768", "sve896", "sve1024", "sve1152", "sve1280", @@ -159,7 +159,7 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(Cp= uModelExpansionType type, } } =20 - obj =3D object_new(object_class_get_name(oc)); + obj =3D object_new_with_class(oc); =20 if (qdict_in) { Visitor *visitor; @@ -175,7 +175,10 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(C= puModelExpansionType type, i =3D 0; while ((name =3D cpu_model_advertised_features[i++]) !=3D NULL) { if (qdict_get(qdict_in, name)) { - if (!object_property_set(obj, name, visitor, &err)) { + ClassProperty *cp =3D class_property_find(oc, name); + if (cp + ? !class_property_set(oc, cp, visitor, &err) + : !object_property_set(obj, name, visitor, &err)) { break; } } @@ -207,12 +210,20 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(= CpuModelExpansionType type, i =3D 0; while ((name =3D cpu_model_advertised_features[i++]) !=3D NULL) { ObjectProperty *prop =3D object_property_find(obj, name); - if (prop) { - QObject *value; + QObject *value =3D NULL; =20 + if (prop) { assert(prop->get); value =3D object_property_get_qobject(obj, name, &error_abort); + } else { + ClassProperty *cprop =3D class_property_find(oc, name); =20 + if (cprop) { + assert(cprop->get); + value =3D class_property_get_qobject(oc, name, &error_abor= t); + } + } + if (value) { qdict_put_obj(qdict_out, name, value); } } --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770196; cv=none; d=zohomail.com; s=zohoarc; b=kiBb/Cmt9SMXywU2BYqUHCFckqU5z+uLij8BsGfIVFg06n+cAggeAg4mFDO3duX6ZY/5TND65Ld+z7kknKoxcZ68T2xwa1kfEjyIExYvqeeP+lvh0kRda/ymREgK5k5MV6WyWiuHRFCmH05I13+BbbGgCfg0EbEjHip/dFHEEeY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770196; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9dq2GNw8hTG6FuOywlRgnm7eV4dHAv+6eWtmKAnnuvM=; b=KUPKv69eUHMZv9zcUoxmJhYfbQRb131jtyGGckpJ0UpRBulFSmh6rXUjC0b91f48LyR0IHWW+wdbfv7IuSiFGx+KmKwo6yhxOl61KlJEXrUkqsikwb31ulzUR2nm+BYD4hUa7S3h83/eHchjkFyg4/G3y8RUid3OV8r5DK70P7I= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 167277019686290.12051379379875; Tue, 3 Jan 2023 10:23:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrq-0000i4-8U; Tue, 03 Jan 2023 13:18:30 -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 1pClro-0000hS-54 for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:28 -0500 Received: from mail-vs1-xe34.google.com ([2607:f8b0:4864:20::e34]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClrm-0005N1-AR for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:27 -0500 Received: by mail-vs1-xe34.google.com with SMTP id a66so32590147vsa.6 for ; Tue, 03 Jan 2023 10:18:25 -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.18.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:18:24 -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=9dq2GNw8hTG6FuOywlRgnm7eV4dHAv+6eWtmKAnnuvM=; b=ldD3932VuXmNbkNYj/Isy5eNYSF/pSk9KDHjhco/Sj2chf5ZGUWguR7wD3wgZEdaYk FhLxD9xzsLkrhs8VOLRIRti3Hz6HVZFh0U1vAxUc3GBzs3+6211nnxUG1ctgqnPTse20 RKK6Z/7zBrX53PAsszBtzv0VyqZn5TF4yozItgyh5zjYa78a+Er9ZutB7JGhBNpK/Hyw oCq5A1EDJDXsVg24H2HyAe9K8OeCc2vO2+b/cTcsPncWAL0BU/6AZyHOEi00QRci9p/J AuGFgU64H1QzTrniQhhVBs6gA/Q4gZLS0rpPhvTW6VAHlWzTSDQ69DKDtlsLsMIvH8ya 9Byw== 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=9dq2GNw8hTG6FuOywlRgnm7eV4dHAv+6eWtmKAnnuvM=; b=FUR/dD6ujQ0F2b0+CuhQ+v5tKzf4hBXxLrCyWVUuTKjBUBhI+OAR4rFmZHjJ1opmSh pOf2aMlR4ekVIN5B+XYyje/NeeYu0Wdc5E2gtVYIZ6vG/ZlLqbI/DBadg3G9iLo/3k9f a0qqOp7b9/Q9hV/6bhjt2qHUR+ixh6LSWn5KIfl2o7vamjGuuEsJl7W7XvrSCx5ETh2V /2A0s2cxPIfzbS6Kyob4y2kZ8pAq9aW95+4Bfwi+lUUUqTTAJY8t1MggtBqG1GeYwTyP almZqH6ftft2Ui7akFZITJY9hxH85EMH2ImZEEA3u1dzAs6JckrxKKYH+oWr75cUaYTR WkzA== X-Gm-Message-State: AFqh2krlbtgriFaCTMTKqbls0hlRUMgY5uMZ/XVPl4KwY3X3At3a4WeP 8TlkvWvFdOQ0xf6+IFmDPIKtS8Gg501VpecA47I= X-Google-Smtp-Source: AMrXdXtuxB23vYnIrlg306dHDJLk+YTtjdTjxsx86xPbLwd42ZOP2GQJjTYbWtV8O8WgkCjKV7YQsQ== X-Received: by 2002:a05:6102:38cc:b0:3c6:cf3d:8381 with SMTP id k12-20020a05610238cc00b003c6cf3d8381mr18135061vst.19.1672769905165; Tue, 03 Jan 2023 10:18:25 -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 32/40] target/arm: Move "midr" to class property Date: Tue, 3 Jan 2023 10:16:38 -0800 Message-Id: <20230103181646.55711-33-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::e34; envelope-from=richard.henderson@linaro.org; helo=mail-vs1-xe34.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770197809100001 Content-Type: text/plain; charset="utf-8" With the movement of the property, we can remove the field from the cpu entirely, using only the class. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/cpu.h | 1 - hw/arm/xilinx_zynq.c | 9 ++++++--- hw/intc/armv7m_nvic.c | 2 +- target/arm/cpu.c | 18 ++++++++++++++++-- target/arm/helper.c | 14 ++++++++------ 5 files changed, 31 insertions(+), 13 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 4b47a420d5..f2dceae0e7 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -956,7 +956,6 @@ struct ArchCPU { * field by reading the value from the KVM vCPU. */ ARMISARegisters isar; - uint64_t midr; uint32_t revidr; uint32_t reset_fpsid; uint64_t ctr; diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c index 3190cc0b8d..3e5b4f4483 100644 --- a/hw/arm/xilinx_zynq.c +++ b/hw/arm/xilinx_zynq.c @@ -177,6 +177,7 @@ static inline int zynq_init_spi_flashes(uint32_t base_a= ddr, qemu_irq irq, static void zynq_init(MachineState *machine) { ZynqMachineState *zynq_machine =3D ZYNQ_MACHINE(machine); + ObjectClass *cpu_class; ARMCPU *cpu; MemoryRegion *address_space_mem =3D get_system_memory(); MemoryRegion *ocm_ram =3D g_new(MemoryRegion, 1); @@ -191,7 +192,11 @@ static void zynq_init(MachineState *machine) exit(EXIT_FAILURE); } =20 - cpu =3D ARM_CPU(object_new(machine->cpu_type)); + cpu_class =3D object_class_by_name(machine->cpu_type); + + class_property_set_uint(cpu_class, "midr", ZYNQ_BOARD_MIDR, &error_fat= al); + + cpu =3D ARM_CPU(object_new_with_class(cpu_class)); =20 /* By default A9 CPUs have EL3 enabled. This board does not * currently support EL3 so the CPU EL3 property is disabled before @@ -201,8 +206,6 @@ static void zynq_init(MachineState *machine) object_property_set_bool(OBJECT(cpu), "has_el3", false, &error_fat= al); } =20 - object_property_set_int(OBJECT(cpu), "midr", ZYNQ_BOARD_MIDR, - &error_fatal); object_property_set_int(OBJECT(cpu), "reset-cbar", MPCORE_PERIPHBASE, &error_fatal); qdev_realize(DEVICE(cpu), NULL, &error_fatal); diff --git a/hw/intc/armv7m_nvic.c b/hw/intc/armv7m_nvic.c index 1f7763964c..92f754a74f 100644 --- a/hw/intc/armv7m_nvic.c +++ b/hw/intc/armv7m_nvic.c @@ -1039,7 +1039,7 @@ static uint32_t nvic_readl(NVICState *s, uint32_t off= set, MemTxAttrs attrs) } return cpu->revidr; case 0xd00: /* CPUID Base. */ - return cpu->midr; + return ARM_CPU_GET_CLASS(cpu)->midr; case 0xd04: /* Interrupt Control State (ICSR) */ /* VECTACTIVE */ val =3D cpu->env.v7m.exception; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 22a6ccaece..7d68c50d7c 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1209,7 +1209,6 @@ static void arm_cpu_initfn(Object *obj) cpu->env.features =3D acc->features; cpu->isar =3D acc->isar; =20 - cpu->midr =3D acc->midr; cpu->ctr =3D acc->ctr; cpu->pmceid0 =3D acc->pmceid0; cpu->pmceid1 =3D acc->pmceid1; @@ -2120,7 +2119,6 @@ static void cpu_arm_get_mp_affinity(Object *obj, Visi= tor *v, const char *name, } =20 static Property arm_cpu_properties[] =3D { - DEFINE_PROP_UINT64("midr", ARMCPU, midr, 0), DEFINE_PROP_INT32("node-id", ARMCPU, node_id, CPU_UNSET_NUMA_NODE_ID), DEFINE_PROP_INT32("core-count", ARMCPU, core_count, -1), DEFINE_PROP_END_OF_LIST() @@ -2173,6 +2171,17 @@ static const struct TCGCPUOps arm_tcg_ops =3D { }; #endif /* CONFIG_TCG */ =20 +static bool arm_class_prop_uint64_ofs(ObjectClass *oc, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + ARMCPUClass *acc =3D ARM_CPU_CLASS(oc); + uintptr_t ofs =3D (uintptr_t)opaque; + uint64_t *ptr =3D (void *)acc + ofs; + + return visit_type_uint64(v, name, ptr, errp); +} + static void arm_cpu_class_init(ObjectClass *oc, void *data) { ARMCPUClass *acc =3D ARM_CPU_CLASS(oc); @@ -2220,6 +2229,11 @@ static void arm_cpu_class_init(ObjectClass *oc, void= *data) */ acc->dtb_compatible =3D "qemu,unknown"; acc->kvm_target =3D QEMU_KVM_ARM_TARGET_NONE; + + class_property_add(oc, "midr", "uint64", NULL, + arm_class_prop_uint64_ofs, + arm_class_prop_uint64_ofs, + (void *)(uintptr_t)offsetof(ARMCPUClass, midr)); } =20 static void arm_cpu_leaf_class_init(ObjectClass *oc, void *data) diff --git a/target/arm/helper.c b/target/arm/helper.c index 43756e130a..d18200ed16 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -7443,6 +7443,8 @@ void register_cp_regs_for_features(ARMCPU *cpu) { /* Register all the coprocessor registers based on feature bits */ CPUARMState *env =3D &cpu->env; + ARMCPUClass *acc =3D ARM_CPU_GET_CLASS(cpu); + if (arm_feature(env, ARM_FEATURE_M)) { /* M profile has no coprocessor registers */ return; @@ -7926,12 +7928,12 @@ void register_cp_regs_for_features(ARMCPU *cpu) { .name =3D "VPIDR", .state =3D ARM_CP_STATE_AA32, .cp =3D 15, .opc1 =3D 4, .crn =3D 0, .crm =3D 0, .opc2 =3D 0, .access =3D PL2_RW, .accessfn =3D access_el3_aa32ns, - .resetvalue =3D cpu->midr, + .resetvalue =3D acc->midr, .type =3D ARM_CP_ALIAS | ARM_CP_EL3_NO_EL2_C_NZ, .fieldoffset =3D offsetoflow32(CPUARMState, cp15.vpidr_el2) = }, { .name =3D "VPIDR_EL2", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 4, .crn =3D 0, .crm =3D 0, .opc2 =3D = 0, - .access =3D PL2_RW, .resetvalue =3D cpu->midr, + .access =3D PL2_RW, .resetvalue =3D acc->midr, .type =3D ARM_CP_EL3_NO_EL2_C_NZ, .fieldoffset =3D offsetof(CPUARMState, cp15.vpidr_el2) }, { .name =3D "VMPIDR", .state =3D ARM_CP_STATE_AA32, @@ -8106,7 +8108,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) */ { .name =3D "MIDR", .cp =3D 15, .crn =3D 0, .crm =3D 0, .opc1 =3D 0, .opc2 =3D C= P_ANY, - .access =3D PL1_R, .resetvalue =3D cpu->midr, + .access =3D PL1_R, .resetvalue =3D acc->midr, .writefn =3D arm_cp_write_ignore, .raw_writefn =3D raw_write, .readfn =3D midr_read, .fieldoffset =3D offsetof(CPUARMState, cp15.c0_cpuid), @@ -8131,16 +8133,16 @@ void register_cp_regs_for_features(ARMCPU *cpu) ARMCPRegInfo id_v8_midr_cp_reginfo[] =3D { { .name =3D "MIDR_EL1", .state =3D ARM_CP_STATE_BOTH, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 0, .crm =3D 0, .opc2 =3D = 0, - .access =3D PL1_R, .type =3D ARM_CP_NO_RAW, .resetvalue =3D = cpu->midr, + .access =3D PL1_R, .type =3D ARM_CP_NO_RAW, .resetvalue =3D = acc->midr, .fieldoffset =3D offsetof(CPUARMState, cp15.c0_cpuid), .readfn =3D midr_read }, /* crn =3D 0 op1 =3D 0 crm =3D 0 op2 =3D 4,7 : AArch32 aliases= of MIDR */ { .name =3D "MIDR", .type =3D ARM_CP_ALIAS | ARM_CP_CONST, .cp =3D 15, .crn =3D 0, .crm =3D 0, .opc1 =3D 0, .opc2 =3D 4, - .access =3D PL1_R, .resetvalue =3D cpu->midr }, + .access =3D PL1_R, .resetvalue =3D acc->midr }, { .name =3D "MIDR", .type =3D ARM_CP_ALIAS | ARM_CP_CONST, .cp =3D 15, .crn =3D 0, .crm =3D 0, .opc1 =3D 0, .opc2 =3D 7, - .access =3D PL1_R, .resetvalue =3D cpu->midr }, + .access =3D PL1_R, .resetvalue =3D acc->midr }, { .name =3D "REVIDR_EL1", .state =3D ARM_CP_STATE_BOTH, .opc0 =3D 3, .opc1 =3D 0, .crn =3D 0, .crm =3D 0, .opc2 =3D = 6, .access =3D PL1_R, --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770240; cv=none; d=zohomail.com; s=zohoarc; b=U7+fJwgDkDSrzLnhQZpzOTb1ZxyooQ1QLUcrcQ0Hl8/k2+OPEFv+Ie7l3+kt7HoGMk2TbOBd0exLQssbRs9ESoTCd/NIdOT/o+E5UkKALrhJGwYDSAwGrBRdwhyDp1jIlUM0PftjXIYwHUrXQhaW935UO9enDfnWdp8blNyM91c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770240; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AoAnTqEKYUyofNs53oxpjz0CHNCNiHX3yNW6NklBHxc=; b=oG4Kc2n118IPUKO1vUiWpK/eSVhye5+8qbm4o72I6vFfKvrOR5DY0v33FfH2GujH72L/m/eF0ROAnxESyQw4q26ZETarzJp11WAGgcM8LNLgE3l/1OHkgD7/LxlN3SqxQBwAmriY7xtg/V1ZvCSyGoV3CeKy0vc+UO2Yl+afSmA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770240002614.1877574130683; Tue, 3 Jan 2023 10:24:00 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrs-0000re-PK; Tue, 03 Jan 2023 13:18:32 -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 1pClrr-0000kJ-3C for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:31 -0500 Received: from mail-qv1-xf35.google.com ([2607:f8b0:4864:20::f35]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClrp-0005NJ-4H for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:30 -0500 Received: by mail-qv1-xf35.google.com with SMTP id i12so21971381qvs.2 for ; Tue, 03 Jan 2023 10:18:28 -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.18.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:18:27 -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=AoAnTqEKYUyofNs53oxpjz0CHNCNiHX3yNW6NklBHxc=; b=A1OdUv5XhgoYnJ9jUjAgslxUNeEDceQkWQU+o+tkk5oMWFcXXegUF0K6aUjiIUAcVT cDxC+1lrw5fhFVJI1/MjWIYrGx4Pn65ZQYcq0QLgVhhrwMactwNSKyF124gw0Lvk6MoY +d4r4TxzeNfPc2vNTt3czI9QoXkWtjgPixQePLMqLMU4nPegH/89Y8hHQu2WGmZV3ryk f1ES/ypi6GHumeiGCmuRWyYfTrqD9qBvMexgApDkqv3CUumgyxPB2laUAFKNYj5UlkvB DPLO2+jcwT1VuV5gEQWXXfAJyGu42gizXq/rVXGElPNqKjdEwLh85og44vqSXZNYKOsr nq4Q== 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=AoAnTqEKYUyofNs53oxpjz0CHNCNiHX3yNW6NklBHxc=; b=jMUJe4Tob2XOSRIVX4GKh9iMP7XcE5b6rhX1Gpk6gEY5bHQlTlcPrrCxXyu939rvq3 UvLlI7TktEfAXbC0aLRiMGkZuHHu14nzLkceMrZbhGFwYc5EAbWEEv5ego3aqw4f1gCW BENCXZxEer/TF8nb0IsrWFzLMMisURvi6KeFufhUVFnRDMePPuGNwwG/2tNvQR4M6OFN bXGJ8CnVBs7CLKEZQj1QaO8h/RiVJbhXZHzq+2KSst/IqcKOLewyIAONFZTp2M0oHKNo u6D6pWd3Z/rYtMTLa/yGsV+a5jvWex4BDUpqpzf/ky8q3bkJ9DmE1L0jgxLvDRa9mv/3 PGzg== X-Gm-Message-State: AFqh2kprGcqyYruZdVZNrubFR27Ref7h8PbL0Doeci+va3peFSmlo+SD 0B4Zmaj0PqV2IiHBAO2zDfKZdvZqTrorC1HaO/4= X-Google-Smtp-Source: AMrXdXsYVzfvZwvtWdRkhrWC3xYIoC33SZgeSd+rkf85Bv2vw3/EeBBw7PT4JAauG157BAfkK5cIyw== X-Received: by 2002:ad4:548a:0:b0:531:d60f:6a98 with SMTP id pv10-20020ad4548a000000b00531d60f6a98mr4924542qvb.38.1672769908122; Tue, 03 Jan 2023 10:18:28 -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 33/40] target/arm: Move "cntfrq" to class property Date: Tue, 3 Jan 2023 10:16:39 -0800 Message-Id: <20230103181646.55711-34-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::f35; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf35.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770240839100003 Content-Type: text/plain; charset="utf-8" With the movement of the property, we can remove the field from the cpu entirely, using only the class. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/cpu-qom.h | 3 +++ target/arm/cpu.h | 3 --- hw/arm/aspeed_ast2600.c | 6 +++-- target/arm/cpu.c | 50 +++++++++++++++++++++++------------------ target/arm/helper.c | 3 ++- 5 files changed, 37 insertions(+), 28 deletions(-) diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h index 6b113d7fe6..2d6fa38a30 100644 --- a/target/arm/cpu-qom.h +++ b/target/arm/cpu-qom.h @@ -154,6 +154,9 @@ struct ARMCPUClass { */ uint64_t ccsidr[16]; =20 + /* Generic timer counter frequency, in Hz */ + uint64_t gt_cntfrq_hz; + uint32_t revidr; uint32_t id_afr0; uint32_t reset_fpsid; diff --git a/target/arm/cpu.h b/target/arm/cpu.h index f2dceae0e7..e425846007 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -1019,9 +1019,6 @@ struct ArchCPU { =20 ARMVQMap sve_vq; ARMVQMap sme_vq; - - /* Generic timer counter frequency, in Hz */ - uint64_t gt_cntfrq_hz; }; =20 unsigned int gt_cntfrq_period_ns(ARMCPU *cpu); diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c index cd75465c2b..bb8579546e 100644 --- a/hw/arm/aspeed_ast2600.c +++ b/hw/arm/aspeed_ast2600.c @@ -145,6 +145,7 @@ static void aspeed_soc_ast2600_init(Object *obj) { AspeedSoCState *s =3D ASPEED_SOC(obj); AspeedSoCClass *sc =3D ASPEED_SOC_GET_CLASS(s); + ObjectClass *cpu_class; int i; char socname[8]; char typename[64]; @@ -153,6 +154,9 @@ static void aspeed_soc_ast2600_init(Object *obj) g_assert_not_reached(); } =20 + cpu_class =3D object_class_by_name(sc->cpu_type); + class_property_set_uint(cpu_class, "cntfrq", 1125000000, &error_abort); + for (i =3D 0; i < sc->num_cpus; i++) { object_initialize_child(obj, "cpu[*]", &s->cpu[i], sc->cpu_type); } @@ -305,8 +309,6 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev= , Error **errp) object_property_set_int(OBJECT(&s->cpu[i]), "mp-affinity", aspeed_calc_affinity(i), &error_abort); =20 - object_property_set_int(OBJECT(&s->cpu[i]), "cntfrq", 1125000000, - &error_abort); object_property_set_bool(OBJECT(&s->cpu[i]), "neon", false, &error_abort); object_property_set_link(OBJECT(&s->cpu[i]), "memory", diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 7d68c50d7c..bc4a052e4c 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1277,10 +1277,6 @@ static void arm_cpu_initfn(Object *obj) } } =20 -static Property arm_cpu_gt_cntfrq_property =3D - DEFINE_PROP_UINT64("cntfrq", ARMCPU, gt_cntfrq_hz, - NANOSECONDS_PER_SECOND / GTIMER_SCALE); - static Property arm_cpu_reset_cbar_property =3D DEFINE_PROP_UINT64("reset-cbar", ARMCPU, reset_cbar, 0); =20 @@ -1342,6 +1338,12 @@ static void arm_set_pmu(Object *obj, bool value, Err= or **errp) =20 unsigned int gt_cntfrq_period_ns(ARMCPU *cpu) { + ARMCPUClass *acc =3D ARM_CPU_GET_CLASS(cpu); + + if (!arm_class_feature(acc, ARM_FEATURE_GENERIC_TIMER)) { + return GTIMER_SCALE; + } + /* * The exact approach to calculating guest ticks is: * @@ -1360,8 +1362,8 @@ unsigned int gt_cntfrq_period_ns(ARMCPU *cpu) * Finally, CNTFRQ is effectively capped at 1GHz to ensure our scale f= actor * cannot become zero. */ - return NANOSECONDS_PER_SECOND > cpu->gt_cntfrq_hz ? - NANOSECONDS_PER_SECOND / cpu->gt_cntfrq_hz : 1; + return (NANOSECONDS_PER_SECOND > acc->gt_cntfrq_hz ? + NANOSECONDS_PER_SECOND / acc->gt_cntfrq_hz : 1); } =20 static void arm_cpu_post_init(Object *obj) @@ -1466,10 +1468,6 @@ static void arm_cpu_post_init(Object *obj) =20 qdev_property_add_static(DEVICE(obj), &arm_cpu_cfgend_property); =20 - if (arm_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER)) { - qdev_property_add_static(DEVICE(cpu), &arm_cpu_gt_cntfrq_property); - } - if (kvm_enabled()) { kvm_arm_add_vcpu_properties(obj); } @@ -1614,18 +1612,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Erro= r **errp) } =20 { - uint64_t scale; - - if (arm_feature(env, ARM_FEATURE_GENERIC_TIMER)) { - if (!cpu->gt_cntfrq_hz) { - error_setg(errp, "Invalid CNTFRQ: %"PRId64"Hz", - cpu->gt_cntfrq_hz); - return; - } - scale =3D gt_cntfrq_period_ns(cpu); - } else { - scale =3D GTIMER_SCALE; - } + uint64_t scale =3D gt_cntfrq_period_ns(cpu); =20 cpu->gt_timer[GTIMER_PHYS] =3D timer_new(QEMU_CLOCK_VIRTUAL, scale, arm_gt_ptimer_cb, cpu); @@ -2242,6 +2229,7 @@ static void arm_cpu_leaf_class_init(ObjectClass *oc, = void *data) =20 acc->cp_regs =3D g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free); + acc->gt_cntfrq_hz =3D NANOSECONDS_PER_SECOND / GTIMER_SCALE; =20 acc->info =3D data; if (acc->info->class_init) { @@ -2308,6 +2296,16 @@ static void arm_cpu_leaf_class_init(ObjectClass *oc,= void *data) if (arm_class_feature(acc, ARM_FEATURE_M)) { set_class_feature(acc, ARM_FEATURE_PMSA); } + +#ifndef CONFIG_USER_ONLY + if (arm_class_feature(acc, ARM_FEATURE_GENERIC_TIMER)) { + class_property_add(oc, "cntfrq", "uint64", NULL, + arm_class_prop_uint64_ofs, + arm_class_prop_uint64_ofs, + (void *)(uintptr_t) + offsetof(ARMCPUClass, gt_cntfrq_hz)); + } +#endif /* CONFIG_USER_ONLY */ } =20 static bool arm_cpu_class_late_init(ObjectClass *oc, Error **errp) @@ -2320,6 +2318,14 @@ static bool arm_cpu_class_late_init(ObjectClass *oc,= Error **errp) } } =20 +#ifndef CONFIG_USER_ONLY + /* TODO: Perhaps better to put this check in a property set hook. */ + if (!acc->gt_cntfrq_hz) { + error_setg(errp, "Invalid CNTFRQ: %"PRId64"Hz", acc->gt_cntfrq_hz); + return false; + } +#endif /* CONFIG_USER_ONLY */ + /* Run some consistency checks for TCG. */ if (tcg_enabled()) { bool no_aa32 =3D arm_class_feature(acc, ARM_FEATURE_AARCH64) && diff --git a/target/arm/helper.c b/target/arm/helper.c index d18200ed16..67d32c2e59 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -2977,8 +2977,9 @@ void arm_gt_hvtimer_cb(void *opaque) static void arm_gt_cntfrq_reset(CPUARMState *env, const ARMCPRegInfo *opaq= ue) { ARMCPU *cpu =3D env_archcpu(env); + ARMCPUClass *acc =3D ARM_CPU_GET_CLASS(cpu); =20 - cpu->env.cp15.c14_cntfrq =3D cpu->gt_cntfrq_hz; + cpu->env.cp15.c14_cntfrq =3D acc->gt_cntfrq_hz; } =20 static const ARMCPRegInfo generic_timer_cp_reginfo[] =3D { --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770025; cv=none; d=zohomail.com; s=zohoarc; b=caJvZN4LtbknrtanibA0H2PhcxskmqVFM8onAgQrsax+oRu0zIqqg3EJ4+Ip3vMxA+Z9J5Wy5lVzHIM/tb/+0KwRoro85TreEO6uJ/0cS7SBzwBWt9/OSRGGyqD8CyMxJQ4fQZLMJHP58+O9QnxHRU/hPcA4zwe5WZlH9zaQSEU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770025; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=aEB0nGrFaxYSQkHhsFi8mtdM2L5qlb+qHO4UJ4164dk=; b=KGjHMtYFZUg+oFGmINLmnorh6OabmqWgPlkhGHHnf9uhLxK5Qop9EbrMdmcpu5I/t5k8H0Fxp9FcjIRiRrWRPi6+f3KIeqHnnXc09//9zVMmXfdUvmiY4BOhroXxNhAJqWMet9iYwH4OUY792IdUbks3P844rV6xEjuLloTN4gQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770025537890.4274749859362; Tue, 3 Jan 2023 10:20:25 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCls3-0000z3-PC; Tue, 03 Jan 2023 13:18:43 -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 1pClrt-0000ud-QG for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:34 -0500 Received: from mail-vs1-xe30.google.com ([2607:f8b0:4864:20::e30]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClrr-0005Gi-ST for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:33 -0500 Received: by mail-vs1-xe30.google.com with SMTP id i188so32589073vsi.8 for ; Tue, 03 Jan 2023 10:18:31 -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.18.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:18:30 -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=aEB0nGrFaxYSQkHhsFi8mtdM2L5qlb+qHO4UJ4164dk=; b=TlypqxXaZZJ22Jk4QzZikCffd42datcqaIAYF1XoajbPDRBi3nNePrFAAuSxUxGvEr fD4j34mc3Sge2aRiDz2GAKeu1/BtMOHKhW5lrudrlK+5Ugf7uOcOL/qqYGgX4V2ZV3Ux Ni+ruI57MQf4iUH7pu3tHryl/6I1j5g2+Um4eNRHlPp40kL9yI0KmvAlyEHsEdRp6vsn ot8Bnd0jXhG2kuxmSmNRqeWkG3ppb6a7zwkA+DUzPRSS9OT4QwR0mOIhK25knWZY5pRh hj8l6U+iA5UMoD1aD2CHtOpupBkSGJVa5ivnt5wAkr8hq37siRadBnI9jC7ahIYQWFal nhLA== 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=aEB0nGrFaxYSQkHhsFi8mtdM2L5qlb+qHO4UJ4164dk=; b=LPHiyq+Aiehq7zeRdbdJzx3ZMmPySl2J2rwK386hvA/p4FRfjIdr7s9FL1DnN3sMfr 5EGjWVeZTwa58sG6KRwFEzKLncK8dwSR5riCS818yl5WfMcbsYHNf/FnUwLemnl4XxG8 UvIZYiBdsenJciMP7duP/4BITJ38sopF7DY2xiyRYb3hHLGwchpp3AAu0fWkjQy56Yd3 D3+O3LzNUK+MmDezkCF2rVdgVefkizVqCgyiePM/05rP1Bv3F/qxPWTtZktSP+Gjl39Z +eaTw9wwXb+TUhoYEDfHoWbvohi7ZXbtiJF1yurfZTpqXuFfZwz9iKs4M8UA8R14jCRm Y/XQ== X-Gm-Message-State: AFqh2kqKWoGmGxIUAxVjuvbgv9dKjdlm2CZaQHa3RnKn3WfwUWBIRprr Z7RshGXKpTMUrc6OtmNT4L3cRMwdGRXXFWyAiHg= X-Google-Smtp-Source: AMrXdXsUZaLwJr4wPxysXLfW45Km+04SFLWPItor2IUxtdBcKn/kR+A/dHbIT1g0O5ajBMw69UgvMQ== X-Received: by 2002:a67:f70b:0:b0:3b5:1986:1914 with SMTP id m11-20020a67f70b000000b003b519861914mr23886333vso.17.1672769911029; Tue, 03 Jan 2023 10:18:31 -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 34/40] target/arm: Move "reset-hivecs" to class property Date: Tue, 3 Jan 2023 10:16:40 -0800 Message-Id: <20230103181646.55711-35-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::e30; envelope-from=richard.henderson@linaro.org; helo=mail-vs1-xe30.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770026938100003 Content-Type: text/plain; charset="utf-8" Remove the reset_hivecs variable entirely and create property accessor functions that directly read/write a bit of the reset value of SCTLR. Signed-off-by: Richard Henderson --- target/arm/cpu.h | 1 - hw/arm/digic.c | 11 ++++----- hw/arm/npcm7xx.c | 9 ++++---- hw/arm/xlnx-zynqmp.c | 11 +++++---- target/arm/cpu.c | 55 +++++++++++++++++++++++++++++++++----------- 5 files changed, 59 insertions(+), 28 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index e425846007..c0baec37d7 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -973,7 +973,6 @@ struct ArchCPU { uint64_t ccsidr[16]; uint64_t reset_cbar; uint32_t reset_auxcr; - bool reset_hivecs; =20 /* * Intermediate values used during property parsing. diff --git a/hw/arm/digic.c b/hw/arm/digic.c index 6df5547977..fed5d38695 100644 --- a/hw/arm/digic.c +++ b/hw/arm/digic.c @@ -34,9 +34,13 @@ static void digic_init(Object *obj) { DigicState *s =3D DIGIC(obj); + const char *cpu_type =3D ARM_CPU_TYPE_NAME("arm946"); + ObjectClass *cpu_class =3D object_class_by_name(cpu_type); int i; =20 - object_initialize_child(obj, "cpu", &s->cpu, ARM_CPU_TYPE_NAME("arm946= ")); + class_property_set_bool(cpu_class, "reset-hivecs", true, &error_abort); + + object_initialize_child(obj, "cpu", &s->cpu, cpu_type); =20 for (i =3D 0; i < DIGIC4_NB_TIMERS; i++) { g_autofree char *name =3D g_strdup_printf("timer[%d]", i); @@ -52,11 +56,6 @@ static void digic_realize(DeviceState *dev, Error **errp) SysBusDevice *sbd; int i; =20 - if (!object_property_set_bool(OBJECT(&s->cpu), "reset-hivecs", true, - errp)) { - return; - } - if (!qdev_realize(DEVICE(&s->cpu), NULL, errp)) { return; } diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c index 41124b7444..97ac4ac7e9 100644 --- a/hw/arm/npcm7xx.c +++ b/hw/arm/npcm7xx.c @@ -390,11 +390,14 @@ static qemu_irq npcm7xx_irq(NPCM7xxState *s, int n) static void npcm7xx_init(Object *obj) { NPCM7xxState *s =3D NPCM7XX(obj); + const char *cpu_type =3D ARM_CPU_TYPE_NAME("cortex-a9"); + ObjectClass *cpu_class =3D object_class_by_name(cpu_type); int i; =20 + class_property_set_bool(cpu_class, "reset-hivecs", true, &error_abort); + for (i =3D 0; i < NPCM7XX_MAX_NUM_CPUS; i++) { - object_initialize_child(obj, "cpu[*]", &s->cpu[i], - ARM_CPU_TYPE_NAME("cortex-a9")); + object_initialize_child(obj, "cpu[*]", &s->cpu[i], cpu_type); } =20 object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_P= RIV); @@ -466,8 +469,6 @@ static void npcm7xx_realize(DeviceState *dev, Error **e= rrp) &error_abort); object_property_set_int(OBJECT(&s->cpu[i]), "reset-cbar", NPCM7XX_GIC_CPU_IF_ADDR, &error_abort); - object_property_set_bool(OBJECT(&s->cpu[i]), "reset-hivecs", true, - &error_abort); =20 /* Disable security extensions. */ object_property_set_bool(OBJECT(&s->cpu[i]), "has_el3", false, diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c index 335cfc417d..13ab999eb8 100644 --- a/hw/arm/xlnx-zynqmp.c +++ b/hw/arm/xlnx-zynqmp.c @@ -243,8 +243,6 @@ static void xlnx_zynqmp_create_rpu(MachineState *ms, Xl= nxZynqMPState *s, s->boot_cpu_ptr =3D &s->rpu_cpu[i]; } =20 - object_property_set_bool(OBJECT(&s->rpu_cpu[i]), "reset-hivecs", t= rue, - &error_abort); if (!qdev_realize(DEVICE(&s->rpu_cpu[i]), NULL, errp)) { return; } @@ -375,6 +373,8 @@ static void xlnx_zynqmp_init(Object *obj) { MachineState *ms =3D MACHINE(qdev_get_machine()); XlnxZynqMPState *s =3D XLNX_ZYNQMP(obj); + const char *cpu_type; + ObjectClass *cpu_class; int i; int num_apus =3D MIN(ms->smp.cpus, XLNX_ZYNQMP_NUM_APU_CPUS); =20 @@ -382,10 +382,13 @@ static void xlnx_zynqmp_init(Object *obj) TYPE_CPU_CLUSTER); qdev_prop_set_uint32(DEVICE(&s->apu_cluster), "cluster-id", 0); =20 + cpu_type =3D ARM_CPU_TYPE_NAME("cortex-a53"); + cpu_class =3D object_class_by_name(cpu_type); + class_property_set_bool(cpu_class, "reset-hivecs", true, &error_abort); + for (i =3D 0; i < num_apus; i++) { object_initialize_child(OBJECT(&s->apu_cluster), "apu-cpu[*]", - &s->apu_cpu[i], - ARM_CPU_TYPE_NAME("cortex-a53")); + &s->apu_cpu[i], cpu_type); } =20 object_initialize_child(obj, "gic", &s->gic, gic_class_name()); diff --git a/target/arm/cpu.c b/target/arm/cpu.c index bc4a052e4c..032a2cc00a 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1280,9 +1280,6 @@ static void arm_cpu_initfn(Object *obj) static Property arm_cpu_reset_cbar_property =3D DEFINE_PROP_UINT64("reset-cbar", ARMCPU, reset_cbar, 0); =20 -static Property arm_cpu_reset_hivecs_property =3D - DEFINE_PROP_BOOL("reset-hivecs", ARMCPU, reset_hivecs, false); - #ifndef CONFIG_USER_ONLY static Property arm_cpu_has_el2_property =3D DEFINE_PROP_BOOL("has_el2", ARMCPU, has_el2, true); @@ -1375,10 +1372,6 @@ static void arm_cpu_post_init(Object *obj) qdev_property_add_static(DEVICE(obj), &arm_cpu_reset_cbar_property= ); } =20 - if (!arm_feature(&cpu->env, ARM_FEATURE_M)) { - qdev_property_add_static(DEVICE(obj), &arm_cpu_reset_hivecs_proper= ty); - } - if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { object_property_add_uint64_ptr(obj, "rvbar", &cpu->rvbar_prop, @@ -1801,10 +1794,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Erro= r **errp) return; } =20 - if (cpu->reset_hivecs) { - cpu->reset_sctlr |=3D (1 << 13); - } - if (cpu->cfgend) { if (arm_feature(&cpu->env, ARM_FEATURE_V7)) { cpu->reset_sctlr |=3D SCTLR_EE; @@ -2169,6 +2158,39 @@ static bool arm_class_prop_uint64_ofs(ObjectClass *o= c, Visitor *v, return visit_type_uint64(v, name, ptr, errp); } =20 +#ifndef CONFIG_USER_ONLY +static bool arm_class_prop_set_sctlrbit(ObjectClass *oc, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + ARMCPUClass *acc =3D ARM_CPU_CLASS(oc); + uint32_t mask =3D (uintptr_t)opaque; + bool val; + + if (!visit_type_bool(v, name, &val, errp)) { + return false; + } + + if (val) { + acc->reset_sctlr |=3D mask; + } else { + acc->reset_sctlr &=3D ~mask; + } + return true; +} + +static bool arm_class_prop_get_sctlrbit(ObjectClass *oc, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + ARMCPUClass *acc =3D ARM_CPU_CLASS(oc); + uint32_t mask =3D (uintptr_t)opaque; + bool val =3D acc->reset_sctlr & mask; + + return visit_type_bool(v, name, &val, errp); +} +#endif /* !CONFIG_USER_ONLY */ + static void arm_cpu_class_init(ObjectClass *oc, void *data) { ARMCPUClass *acc =3D ARM_CPU_CLASS(oc); @@ -2305,7 +2327,14 @@ static void arm_cpu_leaf_class_init(ObjectClass *oc,= void *data) (void *)(uintptr_t) offsetof(ARMCPUClass, gt_cntfrq_hz)); } -#endif /* CONFIG_USER_ONLY */ + + if (!arm_class_feature(acc, ARM_FEATURE_M)) { + class_property_add(oc, "reset-hivecs", "bool", NULL, + arm_class_prop_get_sctlrbit, + arm_class_prop_set_sctlrbit, + (void *)((uintptr_t)1 << 13)); + } +#endif /* !CONFIG_USER_ONLY */ } =20 static bool arm_cpu_class_late_init(ObjectClass *oc, Error **errp) @@ -2324,7 +2353,7 @@ static bool arm_cpu_class_late_init(ObjectClass *oc, = Error **errp) error_setg(errp, "Invalid CNTFRQ: %"PRId64"Hz", acc->gt_cntfrq_hz); return false; } -#endif /* CONFIG_USER_ONLY */ +#endif /* !CONFIG_USER_ONLY */ =20 /* Run some consistency checks for TCG. */ if (tcg_enabled()) { --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770129; cv=none; d=zohomail.com; s=zohoarc; b=cwP10P28Dj/cHsEjtLaWBjuuFxLI8yZt05FLXwQbn/5HpLVExzn8re55c7A1bJMXwFwtNpnHx0OTAvOnx7svGkGSexXPAZRbEmpwiUBoD4LBHgvPI6xUj4XO4JprlOCSrOFEiP9+PQikb7F8aOvZwfbRXRpZyFP38Qeu6LKuR1Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770129; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=iCYu68/AsQJDDTxu6B7ticUbbeKteDS0WJXiIHlsiNQ=; b=FiKMFPUoGcE2jzzUBA1b6c7VjDF0+p20ajaEE2pcBWPAZDzKL2/aclZkQdVoVFS6PU9IKmy48TimpGeIL4pqDQfqS7ohTt+cGFOlsB0vX9/m/iqdd9L2GdId3JebxDq4WS5YYD7jpRy6il2/UFVcFVa1mTH+EbUlg/GFSgzFu0A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770129027115.10652389553377; Tue, 3 Jan 2023 10:22:09 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCls6-00018S-FD; Tue, 03 Jan 2023 13:18:46 -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 1pClrx-0000zC-1h for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:43 -0500 Received: from mail-qv1-xf2b.google.com ([2607:f8b0:4864:20::f2b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClru-0005O6-SD for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:36 -0500 Received: by mail-qv1-xf2b.google.com with SMTP id w10so18876850qvn.11 for ; Tue, 03 Jan 2023 10:18:34 -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.18.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:18:33 -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=iCYu68/AsQJDDTxu6B7ticUbbeKteDS0WJXiIHlsiNQ=; b=NYRXx+bKAavGLJtXYqPL295Qczs1qTCu7ZNqpKMLQxdW/RJEr4x2wCEhaHsRBZuYeg huKAwEWNGXopTc8xBfJBw9Mq76j0cMtnK6O7R2082rKu/SM3fHPcV6W+GZCQkOmyGIrw pADwrEu6lY1oJ+kYtYlQQC0fX5DgJuK7FdLOL55Kd5StdkpCOfwFNAIB8vxk5httWbj5 HLocVczpJNREcFNuPvEH02wk+eajFHIv9r1YY055Kn3GvefTJaiHViBRlQ9z4hqLrj3/ MHY6HniQyiBYwN7u3pN8fNz87BcMdVWXiZIaUJxGG1aGLIouWbNJzNj+xNjm/5vMG4bJ yXVw== 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=iCYu68/AsQJDDTxu6B7ticUbbeKteDS0WJXiIHlsiNQ=; b=VDs19D00UwWbtWNNt2ID++Jbw4q9mOZgC6/VitXAgJpaWXXzimmcLLFBGzBiV1ipDx /2sMxE01Wj1QSoKY7v7WYkf2GozmnwmN2dBKuwG63Z14mk07vvhiJLR9cYSJ1tZnlOOW sWaVbTZbi7h+TFZlyIMT+73rodOoc7wljSa5Q9StRkq9eEf4xJIX2MuAtYJuwL8E3HHP G5ZxfCbzkibww9PgA6Q8BaTG5t4aGYxPBVj8p+vEVlerwzP5zCKd/Q+QS/brdB4anQM6 dKPLq14y1qK+JC8Sgtl4X1LvA1+vrsG/vWcMddwTNSfTvsTMNp+YXE4mDGGmtsIPiKZo i24w== X-Gm-Message-State: AFqh2kqNfy5D8dRrDbvdVubNT3PPaqCFrrZqd5jnRYeaykDCw7CIw3Ru KnlwNM1idS/vnDuVi6EzCl8H7zyw84nHyHoqxLA= X-Google-Smtp-Source: AMrXdXtB0l/eDLAXgfSGO4ftU7VVtsSq/F8JGP56Ski3RNJRSRhJRepW8DZBW6BSXW/efmmbYhl34g== X-Received: by 2002:a05:6214:4947:b0:52e:6f33:ec2 with SMTP id pe7-20020a056214494700b0052e6f330ec2mr53876174qvb.31.1672769913849; Tue, 03 Jan 2023 10:18:33 -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 35/40] target/arm: Move "has_el2" to class property Date: Tue, 3 Jan 2023 10:16:41 -0800 Message-Id: <20230103181646.55711-36-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::f2b; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf2b.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770129506100001 Content-Type: text/plain; charset="utf-8" With the movement of the property, we can remove the field from the cpu entirely, using only the class. However, late initialization of the "max" cpu, due to its interaction with "host", means that we cannot leave the class property undefined when EL2 is not supported. Adjust the class field to OnOffAuto and generate an error if enabled when not supported. Signed-off-by: Richard Henderson --- target/arm/cpu-qom.h | 4 +++ target/arm/cpu.h | 3 -- hw/arm/allwinner-h3.c | 9 ++++-- hw/arm/vexpress.c | 10 +++--- hw/arm/virt.c | 22 ++++++++----- hw/arm/xlnx-zynqmp.c | 3 +- hw/cpu/a15mpcore.c | 9 +++--- target/arm/cpu.c | 74 ++++++++++++++++++++++++++++++++++++------- 8 files changed, 98 insertions(+), 36 deletions(-) diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h index 2d6fa38a30..fceb557a4d 100644 --- a/target/arm/cpu-qom.h +++ b/target/arm/cpu-qom.h @@ -22,6 +22,7 @@ =20 #include "hw/core/cpu.h" #include "qom/object.h" +#include "qapi/qapi-types-common.h" =20 struct arm_boot_info; =20 @@ -182,6 +183,9 @@ struct ARMCPUClass { * QEMU_KVM_ARM_TARGET_NONE if the kernel doesn't support this CPU typ= e. */ uint32_t kvm_target; + + /* CPU has virtualization extension */ + OnOffAuto has_el2; }; =20 static inline int arm_class_feature(ARMCPUClass *acc, int feature) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index c0baec37d7..3888cdafdf 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -25,7 +25,6 @@ #include "hw/registerfields.h" #include "cpu-qom.h" #include "exec/cpu-defs.h" -#include "qapi/qapi-types-common.h" =20 /* ARM processors have a weak memory model */ #define TCG_GUEST_DEFAULT_MO (0) @@ -887,8 +886,6 @@ struct ArchCPU { /* Current power state, access guarded by BQL */ ARMPSCIState power_state; =20 - /* CPU has virtualization extension */ - bool has_el2; /* CPU has security extension */ bool has_el3; /* CPU has PMU (Performance Monitor Unit) */ diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c index 308ed15552..07484b9f97 100644 --- a/hw/arm/allwinner-h3.c +++ b/hw/arm/allwinner-h3.c @@ -188,12 +188,16 @@ void allwinner_h3_bootrom_setup(AwH3State *s, BlockBa= ckend *blk) static void allwinner_h3_init(Object *obj) { AwH3State *s =3D AW_H3(obj); + const char *cpu_type =3D ARM_CPU_TYPE_NAME("cortex-a7"); + ObjectClass *cpu_class =3D object_class_by_name(cpu_type); =20 s->memmap =3D allwinner_h3_memmap; =20 + /* ??? This is the default for A7. */ + class_property_set_bool(cpu_class, "has_el2", true, &error_abort); + for (int i =3D 0; i < AW_H3_NUM_CPUS; i++) { - object_initialize_child(obj, "cpu[*]", &s->cpus[i], - ARM_CPU_TYPE_NAME("cortex-a7")); + object_initialize_child(obj, "cpu[*]", &s->cpus[i], cpu_type); } =20 object_initialize_child(obj, "gic", &s->gic, TYPE_ARM_GIC); @@ -244,7 +248,6 @@ static void allwinner_h3_realize(DeviceState *dev, Erro= r **errp) =20 /* All exception levels required */ qdev_prop_set_bit(DEVICE(&s->cpus[i]), "has_el3", true); - qdev_prop_set_bit(DEVICE(&s->cpus[i]), "has_el2", true); =20 /* Mark realized */ qdev_realize(DEVICE(&s->cpus[i]), NULL, &error_fatal); diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index e1d1983ae6..211daa8fde 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -208,6 +208,11 @@ static void init_cpus(MachineState *ms, const char *cp= u_type, SysBusDevice *busdev; int n; unsigned int smp_cpus =3D ms->smp.cpus; + ObjectClass *cpu_class =3D object_class_by_name(cpu_type); + + if (!virt) { + class_property_set_bool(cpu_class, "has_el2", false, NULL); + } =20 /* Create the actual CPUs */ for (n =3D 0; n < smp_cpus; n++) { @@ -216,11 +221,6 @@ static void init_cpus(MachineState *ms, const char *cp= u_type, if (!secure) { object_property_set_bool(cpuobj, "has_el3", false, NULL); } - if (!virt) { - if (object_property_find(cpuobj, "has_el2")) { - object_property_set_bool(cpuobj, "has_el2", false, NULL); - } - } =20 if (object_property_find(cpuobj, "reset-cbar")) { object_property_set_int(cpuobj, "reset-cbar", periphbase, diff --git a/hw/arm/virt.c b/hw/arm/virt.c index aed86997c0..dd02e42f97 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2018,6 +2018,7 @@ static void machvirt_init(MachineState *machine) MemoryRegion *secure_sysmem =3D NULL; MemoryRegion *tag_sysmem =3D NULL; MemoryRegion *secure_tag_sysmem =3D NULL; + ObjectClass *cpu_class; int n, virt_max_cpus; bool firmware_loaded; bool aarch64 =3D true; @@ -2032,6 +2033,16 @@ static void machvirt_init(MachineState *machine) =20 possible_cpus =3D mc->possible_cpu_arch_ids(machine); =20 + assert(possible_cpus->len =3D=3D max_cpus); + for (n =3D 0; n < max_cpus; n++) { + assert(strcmp(machine->cpu_type, possible_cpus->cpus[n].type) =3D= =3D 0); + } + + cpu_class =3D object_class_by_name(machine->cpu_type); + if (!vms->virt) { + class_property_set_bool(cpu_class, "has_el2", false, &error_abort); + } + /* * In accelerated mode, the memory map is computed earlier in kvm_type= () * to create a VM with the right number of IPA bits. @@ -2046,7 +2057,7 @@ static void machvirt_init(MachineState *machine) * we are about to deal with. Once this is done, get rid of * the object. */ - cpuobj =3D object_new(possible_cpus->cpus[0].type); + cpuobj =3D object_new_with_class(cpu_class); armcpu =3D ARM_CPU(cpuobj); =20 pa_bits =3D arm_pamax(armcpu); @@ -2143,8 +2154,7 @@ static void machvirt_init(MachineState *machine) =20 create_fdt(vms); =20 - assert(possible_cpus->len =3D=3D max_cpus); - for (n =3D 0; n < possible_cpus->len; n++) { + for (n =3D 0; n < max_cpus; n++) { Object *cpuobj; CPUState *cs; =20 @@ -2152,7 +2162,7 @@ static void machvirt_init(MachineState *machine) break; } =20 - cpuobj =3D object_new(possible_cpus->cpus[n].type); + cpuobj =3D object_new_with_class(cpu_class); object_property_set_int(cpuobj, "mp-affinity", possible_cpus->cpus[n].arch_id, NULL); =20 @@ -2168,10 +2178,6 @@ static void machvirt_init(MachineState *machine) object_property_set_bool(cpuobj, "has_el3", false, NULL); } =20 - if (!vms->virt && object_property_find(cpuobj, "has_el2")) { - object_property_set_bool(cpuobj, "has_el2", false, NULL); - } - if (vmc->kvm_no_adjvtime && object_property_find(cpuobj, "kvm-no-adjvtime")) { object_property_set_bool(cpuobj, "kvm-no-adjvtime", true, NULL= ); diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c index 13ab999eb8..17bad9b4ed 100644 --- a/hw/arm/xlnx-zynqmp.c +++ b/hw/arm/xlnx-zynqmp.c @@ -385,6 +385,7 @@ static void xlnx_zynqmp_init(Object *obj) cpu_type =3D ARM_CPU_TYPE_NAME("cortex-a53"); cpu_class =3D object_class_by_name(cpu_type); class_property_set_bool(cpu_class, "reset-hivecs", true, &error_abort); + class_property_set_bool(cpu_class, "has_el2", s->virt, &error_abort); =20 for (i =3D 0; i < num_apus; i++) { object_initialize_child(OBJECT(&s->apu_cluster), "apu-cpu[*]", @@ -529,8 +530,6 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error= **errp) =20 object_property_set_bool(OBJECT(&s->apu_cpu[i]), "has_el3", s->sec= ure, NULL); - object_property_set_bool(OBJECT(&s->apu_cpu[i]), "has_el2", s->vir= t, - NULL); object_property_set_int(OBJECT(&s->apu_cpu[i]), "reset-cbar", GIC_BASE_ADDR, &error_abort); object_property_set_int(OBJECT(&s->apu_cpu[i]), "core-count", diff --git a/hw/cpu/a15mpcore.c b/hw/cpu/a15mpcore.c index 774ca9987a..6329d25f68 100644 --- a/hw/cpu/a15mpcore.c +++ b/hw/cpu/a15mpcore.c @@ -55,7 +55,6 @@ static void a15mp_priv_realize(DeviceState *dev, Error **= errp) int i; bool has_el3; bool has_el2 =3D false; - Object *cpuobj; =20 gicdev =3D DEVICE(&s->gic); qdev_prop_set_uint32(gicdev, "num-cpu", s->num_cpu); @@ -65,13 +64,15 @@ static void a15mp_priv_realize(DeviceState *dev, Error = **errp) /* Make the GIC's TZ support match the CPUs. We assume that * either all the CPUs have TZ, or none do. */ - cpuobj =3D OBJECT(qemu_get_cpu(0)); + Object *cpuobj =3D OBJECT(qemu_get_cpu(0)); + ObjectClass *cpucls =3D object_get_class(cpuobj); + has_el3 =3D object_property_find(cpuobj, "has_el3") && object_property_get_bool(cpuobj, "has_el3", &error_abort); qdev_prop_set_bit(gicdev, "has-security-extensions", has_el3); + /* Similarly for virtualization support */ - has_el2 =3D object_property_find(cpuobj, "has_el2") && - object_property_get_bool(cpuobj, "has_el2", &error_abort); + has_el2 =3D class_property_get_bool(cpucls, "has_el2", NULL); qdev_prop_set_bit(gicdev, "has-virtualization-extensions", has_el2= ); } =20 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 032a2cc00a..db996d8c3a 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1281,9 +1281,6 @@ static Property arm_cpu_reset_cbar_property =3D DEFINE_PROP_UINT64("reset-cbar", ARMCPU, reset_cbar, 0); =20 #ifndef CONFIG_USER_ONLY -static Property arm_cpu_has_el2_property =3D - DEFINE_PROP_BOOL("has_el2", ARMCPU, has_el2, true); - static Property arm_cpu_has_el3_property =3D DEFINE_PROP_BOOL("has_el3", ARMCPU, has_el3, true); #endif @@ -1391,10 +1388,6 @@ static void arm_cpu_post_init(Object *obj) qdev_prop_allow_set_link_before_realize, OBJ_PROP_LINK_STRONG); } - - if (arm_feature(&cpu->env, ARM_FEATURE_EL2)) { - qdev_property_add_static(DEVICE(obj), &arm_cpu_has_el2_property); - } #endif =20 if (arm_feature(&cpu->env, ARM_FEATURE_PMU)) { @@ -1818,10 +1811,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Erro= r **errp) ID_AA64PFR0, EL3, 0); } =20 - if (!cpu->has_el2) { - unset_feature(env, ARM_FEATURE_EL2); - } - if (!cpu->has_pmu) { unset_feature(env, ARM_FEATURE_PMU); } @@ -2159,6 +2148,34 @@ static bool arm_class_prop_uint64_ofs(ObjectClass *o= c, Visitor *v, } =20 #ifndef CONFIG_USER_ONLY +static bool arm_class_prop_get_auto_ofs(ObjectClass *oc, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + ARMCPUClass *acc =3D ARM_CPU_CLASS(oc); + uintptr_t ofs =3D (uintptr_t)opaque; + OnOffAuto *ptr =3D (void *)acc + ofs; + bool val =3D *ptr =3D=3D ON_OFF_AUTO_ON; + + return visit_type_bool(v, name, &val, errp); +} + +static bool arm_class_prop_set_auto_ofs(ObjectClass *oc, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + ARMCPUClass *acc =3D ARM_CPU_CLASS(oc); + uintptr_t ofs =3D (uintptr_t)opaque; + OnOffAuto *ptr =3D (void *)acc + ofs; + bool val; + + if (visit_type_bool(v, name, &val, errp)) { + *ptr =3D val ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF; + return true; + } + return false; +} + static bool arm_class_prop_set_sctlrbit(ObjectClass *oc, Visitor *v, const char *name, void *opaque, Error **errp) @@ -2334,6 +2351,19 @@ static void arm_cpu_leaf_class_init(ObjectClass *oc,= void *data) arm_class_prop_set_sctlrbit, (void *)((uintptr_t)1 << 13)); } + + /* + * With v8, we cannot yet tell if EL[23] are available, because + * we do not yet know if we're using tcg or host acceleration. + * We will reject incorrect settings during class_late_init. + */ + if (arm_class_feature(acc, ARM_FEATURE_EL2) || + arm_class_feature(acc, ARM_FEATURE_V8)) { + class_property_add(oc, "has_el2", "bool", NULL, + arm_class_prop_get_auto_ofs, + arm_class_prop_set_auto_ofs, + (void *)(uintptr_t)offsetof(ARMCPUClass, has_el= 2)); + } #endif /* !CONFIG_USER_ONLY */ } =20 @@ -2353,6 +2383,28 @@ static bool arm_cpu_class_late_init(ObjectClass *oc,= Error **errp) error_setg(errp, "Invalid CNTFRQ: %"PRId64"Hz", acc->gt_cntfrq_hz); return false; } + + switch (acc->has_el2) { + case ON_OFF_AUTO_AUTO: + acc->has_el2 =3D (arm_class_feature(acc, ARM_FEATURE_EL2) + ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF); + break; + case ON_OFF_AUTO_OFF: + unset_class_feature(acc, ARM_FEATURE_EL2); + acc->isar.id_pfr1 =3D FIELD_DP32(acc->isar.id_pfr1, ID_PFR1, + VIRTUALIZATION, 0); + acc->isar.id_aa64pfr0 =3D FIELD_DP64(acc->isar.id_aa64pfr0, + ID_AA64PFR0, EL2, 0); + break; + case ON_OFF_AUTO_ON: + if (!arm_class_feature(acc, ARM_FEATURE_EL2)) { + error_setg(errp, "CPU does not support EL2"); + return false; + } + break; + default: + g_assert_not_reached(); + } #endif /* !CONFIG_USER_ONLY */ =20 /* Run some consistency checks for TCG. */ --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770065; cv=none; d=zohomail.com; s=zohoarc; b=RJFzVwOLc7e1bVyDU/FzTvmGjgCFZQYNZ2Wc3i5X3QwKXp7IrKDQhQ9YgbEHIPkUv4iz8OrvnlPXYoVLFbno5MEkCIL9opks0hxXMgUTt8KW5gd/sfNAsPGLLcd+EttfAJSD9txCkDC0LbcgH/dyiwqddV7JPR4o+uOXdG5Zauo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770065; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=cEjKn8qgsXWu9xhy89oOazfgxATFsGsm3Jhd9ukMHZ8=; b=B2JeyNBkHLigufNLlfU7tWCvVqU9xfH8Zzqp4u33h6UZvb64jP8EW45Ct8XiZvAX+ZRGebIARgVkqr96KNbHNg3m2vN0NMcG7O2johYb2V8/OJSUoF/BcmjlPTvewNszCF7B9O2XCZLKAB+9OEOr+1TihlTwxfo5vdfwT8pBgPk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770065608494.2401268022577; Tue, 3 Jan 2023 10:21:05 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCls5-000176-Bm; Tue, 03 Jan 2023 13:18:45 -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 1pCls0-0000zF-Ng for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:43 -0500 Received: from mail-vk1-xa2a.google.com ([2607:f8b0:4864:20::a2a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClrx-0005OO-S2 for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:40 -0500 Received: by mail-vk1-xa2a.google.com with SMTP id v81so15688171vkv.5 for ; Tue, 03 Jan 2023 10:18:37 -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.18.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:18:36 -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=cEjKn8qgsXWu9xhy89oOazfgxATFsGsm3Jhd9ukMHZ8=; b=qlKact7TahAyRlVZ+5ZWb2kohoG5Lm14aBHGRh2/pv8MgAQE17iKr2O53keEOsVubZ u+JRT7sKKp7zUuAJ7tn1UVH/m95L29sEc7XvBMCEJ4a7TRfMVPGkWYxlQKgQiKHJ+v5r 4BwQKBwyLxgohi5db3aN5klTJhIYwwIhVotSyCPuXQqi0DQ763BZeyTQEKf2RWis3Yrq G7qphE5OJnhx+iw8r7Cr/0ou4UA3iSPSjCSGHupmcN8upYbpA8MzSGpH5n4MXa0I+7EL op7YWji1arWVNxyPF+Gx84WvQPT60dWzdAYuzldnoDriKsHQ5GFeTGr0X7P1XmIKe1tT S9ZQ== 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=cEjKn8qgsXWu9xhy89oOazfgxATFsGsm3Jhd9ukMHZ8=; b=vOyhZLI7aIIR9NzBdYA1F6yH9MTV9FI5OVY6P+AM/5nrHWevSQjz6RV7Aufg6ntxOn QlegBksY7ovcd4Bz8l8bS+b9bQrWKyAmHUipi8Qz7/EZZAZeKe70ewKTcMwK28bh656D oB26x4rQyfnkR6Zp9ZsQNhp75KHrEhTr28CSHtRYolc69xnoKWGC5WVN23A0Ag2QUxlL PypilgW2QkpsyRjiOVgBeBoqnj5Wu0mtcvvgSrBgO455NeAyCwn10F/jFWystBeQOgFT 9XkaIECdyahIeV7QhIdaX+UQXQfqreo3drFek6TjTbgcvNWXL42gqN+vQ1KLRp0QF5Jw LsaA== X-Gm-Message-State: AFqh2kpq57Tc8yxwQEqt6X7xEJgN+NzHgZqPKjsAzpzQU1T9m+ORJ8gK cr1L6rpczk4EnuZoojxLvC/JssQ8IgREIPvpzHk= X-Google-Smtp-Source: AMrXdXv1QtnExEGlpFOQ79SgTiNbZmXzN+yOIVnQhBNpoF0NhJlgdbbiOWZJwMPG4TeUpJfKH3Q27Q== X-Received: by 2002:a1f:1802:0:b0:3d0:bcff:a591 with SMTP id 2-20020a1f1802000000b003d0bcffa591mr18379677vky.0.1672769916860; Tue, 03 Jan 2023 10:18:36 -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 36/40] target/arm: Move "has_el3" to class property Date: Tue, 3 Jan 2023 10:16:42 -0800 Message-Id: <20230103181646.55711-37-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::a2a; envelope-from=richard.henderson@linaro.org; helo=mail-vk1-xa2a.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770067133100001 Content-Type: text/plain; charset="utf-8" With the movement of the property, we can remove the field from the cpu entirely, using only the class. Signed-off-by: Richard Henderson --- target/arm/cpu-qom.h | 2 ++ target/arm/cpu.h | 2 -- hw/arm/allwinner-h3.c | 5 ++- hw/arm/exynos4210.c | 18 +++++----- hw/arm/integratorcp.c | 12 ++++--- hw/arm/npcm7xx.c | 5 +-- hw/arm/realview.c | 20 +++++------ hw/arm/versatilepb.c | 12 ++++--- hw/arm/vexpress.c | 9 +++-- hw/arm/virt.c | 5 +-- hw/arm/xilinx_zynq.c | 14 ++++---- hw/arm/xlnx-zynqmp.c | 3 +- hw/cpu/a15mpcore.c | 5 ++- hw/cpu/a9mpcore.c | 6 ++-- target/arm/cpu.c | 78 +++++++++++++++++++++++++------------------ 15 files changed, 102 insertions(+), 94 deletions(-) diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h index fceb557a4d..f4e01e0ddb 100644 --- a/target/arm/cpu-qom.h +++ b/target/arm/cpu-qom.h @@ -184,6 +184,8 @@ struct ARMCPUClass { */ uint32_t kvm_target; =20 + /* CPU has security extension */ + OnOffAuto has_el3; /* CPU has virtualization extension */ OnOffAuto has_el2; }; diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 3888cdafdf..5921660d86 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -886,8 +886,6 @@ struct ArchCPU { /* Current power state, access guarded by BQL */ ARMPSCIState power_state; =20 - /* CPU has security extension */ - bool has_el3; /* CPU has PMU (Performance Monitor Unit) */ bool has_pmu; /* CPU has VFP */ diff --git a/hw/arm/allwinner-h3.c b/hw/arm/allwinner-h3.c index 07484b9f97..8ec97961de 100644 --- a/hw/arm/allwinner-h3.c +++ b/hw/arm/allwinner-h3.c @@ -193,7 +193,9 @@ static void allwinner_h3_init(Object *obj) =20 s->memmap =3D allwinner_h3_memmap; =20 + /* All exception levels required. */ /* ??? This is the default for A7. */ + class_property_set_bool(cpu_class, "has_el3", true, &error_abort); class_property_set_bool(cpu_class, "has_el2", true, &error_abort); =20 for (int i =3D 0; i < AW_H3_NUM_CPUS; i++) { @@ -246,9 +248,6 @@ static void allwinner_h3_realize(DeviceState *dev, Erro= r **errp) qdev_prop_set_bit(DEVICE(&s->cpus[i]), "start-powered-off", i > 0); =20 - /* All exception levels required */ - qdev_prop_set_bit(DEVICE(&s->cpus[i]), "has_el3", true); - /* Mark realized */ qdev_realize(DEVICE(&s->cpus[i]), NULL, &error_fatal); } diff --git a/hw/arm/exynos4210.c b/hw/arm/exynos4210.c index 8dafa2215b..bf056ecad7 100644 --- a/hw/arm/exynos4210.c +++ b/hw/arm/exynos4210.c @@ -548,18 +548,20 @@ static void exynos4210_realize(DeviceState *socdev, E= rror **errp) Exynos4210State *s =3D EXYNOS4210_SOC(socdev); MemoryRegion *system_mem =3D get_system_memory(); SysBusDevice *busdev; + ObjectClass *cpu_class; DeviceState *dev, *uart[4], *pl330[3]; int i, n; =20 - for (n =3D 0; n < EXYNOS4210_NCPUS; n++) { - Object *cpuobj =3D object_new(ARM_CPU_TYPE_NAME("cortex-a9")); + cpu_class =3D object_class_by_name(ARM_CPU_TYPE_NAME("cortex-a9")); =20 - /* By default A9 CPUs have EL3 enabled. This board does not curre= ntly - * support EL3 so the CPU EL3 property is disabled before realizat= ion. - */ - if (object_property_find(cpuobj, "has_el3")) { - object_property_set_bool(cpuobj, "has_el3", false, &error_fata= l); - } + /* + * By default A9 CPUs have EL3 enabled. This board does not currently + * support EL3 so the CPU EL3 property is disabled. + */ + class_property_set_bool(cpu_class, "has_el3", false, &error_abort); + + for (n =3D 0; n < EXYNOS4210_NCPUS; n++) { + Object *cpuobj =3D object_new_with_class(cpu_class); =20 s->cpu[n] =3D ARM_CPU(cpuobj); object_property_set_int(cpuobj, "mp-affinity", diff --git a/hw/arm/integratorcp.c b/hw/arm/integratorcp.c index b109ece3ae..9244026f3f 100644 --- a/hw/arm/integratorcp.c +++ b/hw/arm/integratorcp.c @@ -595,17 +595,19 @@ static void integratorcp_init(MachineState *machine) qemu_irq pic[32]; DeviceState *dev, *sic, *icp; DriveInfo *dinfo; + ObjectClass *cpu_class; int i; =20 - cpuobj =3D object_new(machine->cpu_type); + cpu_class =3D object_class_by_name(machine->cpu_type); =20 - /* By default ARM1176 CPUs have EL3 enabled. This board does not + /* + * By default ARM1176 CPUs have EL3 enabled. This board does not * currently support EL3 so the CPU EL3 property is disabled before * realization. */ - if (object_property_find(cpuobj, "has_el3")) { - object_property_set_bool(cpuobj, "has_el3", false, &error_fatal); - } + class_property_set_bool(cpu_class, "has_el3", false, NULL); + + cpuobj =3D object_new_with_class(cpu_class); =20 qdev_realize(DEVICE(cpuobj), NULL, &error_fatal); =20 diff --git a/hw/arm/npcm7xx.c b/hw/arm/npcm7xx.c index 97ac4ac7e9..8dec8e0d12 100644 --- a/hw/arm/npcm7xx.c +++ b/hw/arm/npcm7xx.c @@ -395,6 +395,7 @@ static void npcm7xx_init(Object *obj) int i; =20 class_property_set_bool(cpu_class, "reset-hivecs", true, &error_abort); + class_property_set_bool(cpu_class, "has_el3", false, &error_abort); =20 for (i =3D 0; i < NPCM7XX_MAX_NUM_CPUS; i++) { object_initialize_child(obj, "cpu[*]", &s->cpu[i], cpu_type); @@ -470,10 +471,6 @@ static void npcm7xx_realize(DeviceState *dev, Error **= errp) object_property_set_int(OBJECT(&s->cpu[i]), "reset-cbar", NPCM7XX_GIC_CPU_IF_ADDR, &error_abort); =20 - /* Disable security extensions. */ - object_property_set_bool(OBJECT(&s->cpu[i]), "has_el3", false, - &error_abort); - if (!qdev_realize(DEVICE(&s->cpu[i]), NULL, errp)) { return; } diff --git a/hw/arm/realview.c b/hw/arm/realview.c index d2dc8a8952..0e1a4ff396 100644 --- a/hw/arm/realview.c +++ b/hw/arm/realview.c @@ -81,6 +81,7 @@ static void realview_init(MachineState *machine, MemoryRegion *ram_hack =3D g_new(MemoryRegion, 1); DeviceState *dev, *sysctl, *gpio2, *pl041; SysBusDevice *busdev; + ObjectClass *cpu_class; qemu_irq pic[64]; PCIBus *pci_bus =3D NULL; NICInfo *nd; @@ -115,22 +116,21 @@ static void realview_init(MachineState *machine, break; } =20 - for (n =3D 0; n < smp_cpus; n++) { - Object *cpuobj =3D object_new(machine->cpu_type); + cpu_class =3D object_class_by_name(machine->cpu_type); + /* + * By default A9, A15 and ARM1176 CPUs have EL3 enabled. This board + * does not currently support EL3 so the CPU EL3 property is disabled + * before realization. + */ + class_property_set_bool(cpu_class, "has_el3", false, NULL); =20 - /* By default A9,A15 and ARM1176 CPUs have EL3 enabled. This board - * does not currently support EL3 so the CPU EL3 property is disab= led - * before realization. - */ - if (object_property_find(cpuobj, "has_el3")) { - object_property_set_bool(cpuobj, "has_el3", false, &error_fata= l); - } + for (n =3D 0; n < smp_cpus; n++) { + Object *cpuobj =3D object_new_with_class(cpu_class); =20 if (is_pb && is_mpcore) { object_property_set_int(cpuobj, "reset-cbar", periphbase, &error_fatal); } - qdev_realize(DEVICE(cpuobj), NULL, &error_fatal); =20 cpu_irq[n] =3D qdev_get_gpio_in(DEVICE(cpuobj), ARM_CPU_IRQ); diff --git a/hw/arm/versatilepb.c b/hw/arm/versatilepb.c index ecc1f6cf74..5b8c332f64 100644 --- a/hw/arm/versatilepb.c +++ b/hw/arm/versatilepb.c @@ -182,6 +182,7 @@ static struct arm_boot_info versatile_binfo; =20 static void versatile_init(MachineState *machine, int board_id) { + ObjectClass *cpu_class; Object *cpuobj; ARMCPU *cpu; MemoryRegion *sysmem =3D get_system_memory(); @@ -206,15 +207,16 @@ static void versatile_init(MachineState *machine, int= board_id) exit(1); } =20 - cpuobj =3D object_new(machine->cpu_type); + cpu_class =3D object_class_by_name(machine->cpu_type); =20 - /* By default ARM1176 CPUs have EL3 enabled. This board does not + /* + * By default ARM1176 CPUs have EL3 enabled. This board does not * currently support EL3 so the CPU EL3 property is disabled before * realization. */ - if (object_property_find(cpuobj, "has_el3")) { - object_property_set_bool(cpuobj, "has_el3", false, &error_fatal); - } + class_property_set_bool(cpu_class, "has_el3", false, NULL); + + cpuobj =3D object_new_with_class(cpu_class); =20 qdev_realize(DEVICE(cpuobj), NULL, &error_fatal); =20 diff --git a/hw/arm/vexpress.c b/hw/arm/vexpress.c index 211daa8fde..d23b678d04 100644 --- a/hw/arm/vexpress.c +++ b/hw/arm/vexpress.c @@ -210,17 +210,16 @@ static void init_cpus(MachineState *ms, const char *c= pu_type, unsigned int smp_cpus =3D ms->smp.cpus; ObjectClass *cpu_class =3D object_class_by_name(cpu_type); =20 + if (!secure) { + class_property_set_bool(cpu_class, "has_el3", false, NULL); + } if (!virt) { class_property_set_bool(cpu_class, "has_el2", false, NULL); } =20 /* Create the actual CPUs */ for (n =3D 0; n < smp_cpus; n++) { - Object *cpuobj =3D object_new(cpu_type); - - if (!secure) { - object_property_set_bool(cpuobj, "has_el3", false, NULL); - } + Object *cpuobj =3D object_new_with_class(cpu_class); =20 if (object_property_find(cpuobj, "reset-cbar")) { object_property_set_int(cpuobj, "reset-cbar", periphbase, diff --git a/hw/arm/virt.c b/hw/arm/virt.c index dd02e42f97..c1cabe2413 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -2039,6 +2039,7 @@ static void machvirt_init(MachineState *machine) } =20 cpu_class =3D object_class_by_name(machine->cpu_type); + class_property_set_bool(cpu_class, "has_el3", vms->secure, &error_abor= t); if (!vms->virt) { class_property_set_bool(cpu_class, "has_el2", false, &error_abort); } @@ -2174,10 +2175,6 @@ static void machvirt_init(MachineState *machine) =20 aarch64 &=3D object_property_get_bool(cpuobj, "aarch64", NULL); =20 - if (!vms->secure) { - object_property_set_bool(cpuobj, "has_el3", false, NULL); - } - if (vmc->kvm_no_adjvtime && object_property_find(cpuobj, "kvm-no-adjvtime")) { object_property_set_bool(cpuobj, "kvm-no-adjvtime", true, NULL= ); diff --git a/hw/arm/xilinx_zynq.c b/hw/arm/xilinx_zynq.c index 3e5b4f4483..8b8fe6736a 100644 --- a/hw/arm/xilinx_zynq.c +++ b/hw/arm/xilinx_zynq.c @@ -194,17 +194,15 @@ static void zynq_init(MachineState *machine) =20 cpu_class =3D object_class_by_name(machine->cpu_type); =20 - class_property_set_uint(cpu_class, "midr", ZYNQ_BOARD_MIDR, &error_fat= al); - - cpu =3D ARM_CPU(object_new_with_class(cpu_class)); - - /* By default A9 CPUs have EL3 enabled. This board does not + /* + * By default A9 CPUs have EL3 enabled. This board does not * currently support EL3 so the CPU EL3 property is disabled before * realization. */ - if (object_property_find(OBJECT(cpu), "has_el3")) { - object_property_set_bool(OBJECT(cpu), "has_el3", false, &error_fat= al); - } + class_property_set_bool(cpu_class, "has_el3", false, &error_abort); + class_property_set_uint(cpu_class, "midr", ZYNQ_BOARD_MIDR, &error_abo= rt); + + cpu =3D ARM_CPU(object_new_with_class(cpu_class)); =20 object_property_set_int(OBJECT(cpu), "reset-cbar", MPCORE_PERIPHBASE, &error_fatal); diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c index 17bad9b4ed..86f08a91d9 100644 --- a/hw/arm/xlnx-zynqmp.c +++ b/hw/arm/xlnx-zynqmp.c @@ -385,6 +385,7 @@ static void xlnx_zynqmp_init(Object *obj) cpu_type =3D ARM_CPU_TYPE_NAME("cortex-a53"); cpu_class =3D object_class_by_name(cpu_type); class_property_set_bool(cpu_class, "reset-hivecs", true, &error_abort); + class_property_set_bool(cpu_class, "has_el3", s->secure, &error_abort); class_property_set_bool(cpu_class, "has_el2", s->virt, &error_abort); =20 for (i =3D 0; i < num_apus; i++) { @@ -528,8 +529,6 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error= **errp) s->boot_cpu_ptr =3D &s->apu_cpu[i]; } =20 - object_property_set_bool(OBJECT(&s->apu_cpu[i]), "has_el3", s->sec= ure, - NULL); object_property_set_int(OBJECT(&s->apu_cpu[i]), "reset-cbar", GIC_BASE_ADDR, &error_abort); object_property_set_int(OBJECT(&s->apu_cpu[i]), "core-count", diff --git a/hw/cpu/a15mpcore.c b/hw/cpu/a15mpcore.c index 6329d25f68..e8c0bac02a 100644 --- a/hw/cpu/a15mpcore.c +++ b/hw/cpu/a15mpcore.c @@ -53,7 +53,6 @@ static void a15mp_priv_realize(DeviceState *dev, Error **= errp) DeviceState *gicdev; SysBusDevice *busdev; int i; - bool has_el3; bool has_el2 =3D false; =20 gicdev =3D DEVICE(&s->gic); @@ -66,9 +65,9 @@ static void a15mp_priv_realize(DeviceState *dev, Error **= errp) */ Object *cpuobj =3D OBJECT(qemu_get_cpu(0)); ObjectClass *cpucls =3D object_get_class(cpuobj); + bool has_el3; =20 - has_el3 =3D object_property_find(cpuobj, "has_el3") && - object_property_get_bool(cpuobj, "has_el3", &error_abort); + has_el3 =3D class_property_get_bool(cpucls, "has_el3", NULL); qdev_prop_set_bit(gicdev, "has-security-extensions", has_el3); =20 /* Similarly for virtualization support */ diff --git a/hw/cpu/a9mpcore.c b/hw/cpu/a9mpcore.c index d03f57e579..984e373400 100644 --- a/hw/cpu/a9mpcore.c +++ b/hw/cpu/a9mpcore.c @@ -55,9 +55,12 @@ static void a9mp_priv_realize(DeviceState *dev, Error **= errp) bool has_el3; CPUState *cpu0; Object *cpuobj; + ObjectClass *cpucls; =20 cpu0 =3D qemu_get_cpu(0); cpuobj =3D OBJECT(cpu0); + cpucls =3D object_get_class(cpuobj); + if (strcmp(object_get_typename(cpuobj), ARM_CPU_TYPE_NAME("cortex-a9")= )) { /* We might allow Cortex-A5 once we model it */ error_setg(errp, @@ -81,8 +84,7 @@ static void a9mp_priv_realize(DeviceState *dev, Error **e= rrp) /* Make the GIC's TZ support match the CPUs. We assume that * either all the CPUs have TZ, or none do. */ - has_el3 =3D object_property_find(cpuobj, "has_el3") && - object_property_get_bool(cpuobj, "has_el3", &error_abort); + has_el3 =3D class_property_get_bool(cpucls, "has_el3", &error_abort); qdev_prop_set_bit(gicdev, "has-security-extensions", has_el3); =20 if (!sysbus_realize(SYS_BUS_DEVICE(&s->gic), errp)) { diff --git a/target/arm/cpu.c b/target/arm/cpu.c index db996d8c3a..3262e86e61 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1280,11 +1280,6 @@ static void arm_cpu_initfn(Object *obj) static Property arm_cpu_reset_cbar_property =3D DEFINE_PROP_UINT64("reset-cbar", ARMCPU, reset_cbar, 0); =20 -#ifndef CONFIG_USER_ONLY -static Property arm_cpu_has_el3_property =3D - DEFINE_PROP_BOOL("has_el3", ARMCPU, has_el3, true); -#endif - static Property arm_cpu_cfgend_property =3D DEFINE_PROP_BOOL("cfgend", ARMCPU, cfgend, false); =20 @@ -1377,11 +1372,6 @@ static void arm_cpu_post_init(Object *obj) =20 #ifndef CONFIG_USER_ONLY if (arm_feature(&cpu->env, ARM_FEATURE_EL3)) { - /* Add the has_el3 state CPU property only if EL3 is allowed. Thi= s will - * prevent "has_el3" from existing on CPUs which cannot support EL= 3. - */ - qdev_property_add_static(DEVICE(obj), &arm_cpu_has_el3_property); - object_property_add_link(obj, "secure-memory", TYPE_MEMORY_REGION, (Object **)&cpu->secure_memory, @@ -1583,12 +1573,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Erro= r **errp) current_accel_name()); return; } - if (cpu->has_el3) { - error_setg(errp, - "Cannot enable %s when guest CPU has EL3 enabled", - current_accel_name()); - return; - } if (cpu->tag_memory) { error_setg(errp, "Cannot enable %s when guest CPUs has MTE enabled", @@ -1795,22 +1779,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Erro= r **errp) } } =20 - if (!arm_feature(env, ARM_FEATURE_M) && !cpu->has_el3) { - /* If the has_el3 CPU property is disabled then we need to disable= the - * feature. - */ - unset_feature(env, ARM_FEATURE_EL3); - - /* - * Disable the security extension feature bits in the processor - * feature registers as well. - */ - cpu->isar.id_pfr1 =3D FIELD_DP32(cpu->isar.id_pfr1, ID_PFR1, SECUR= ITY, 0); - cpu->isar.id_dfr0 =3D FIELD_DP32(cpu->isar.id_dfr0, ID_DFR0, COPSD= BG, 0); - cpu->isar.id_aa64pfr0 =3D FIELD_DP64(cpu->isar.id_aa64pfr0, - ID_AA64PFR0, EL3, 0); - } - if (!cpu->has_pmu) { unset_feature(env, ARM_FEATURE_PMU); } @@ -1929,7 +1897,8 @@ static void arm_cpu_realizefn(DeviceState *dev, Error= **errp) #ifndef CONFIG_USER_ONLY MachineState *ms =3D MACHINE(qdev_get_machine()); unsigned int smp_cpus =3D ms->smp.cpus; - bool has_secure =3D cpu->has_el3 || arm_feature(env, ARM_FEATURE_M_SEC= URITY); + bool has_secure =3D arm_feature(env, ARM_FEATURE_EL3) || + arm_feature(env, ARM_FEATURE_M_SECURITY); =20 /* * We must set cs->num_ases to the final value before @@ -2364,6 +2333,13 @@ static void arm_cpu_leaf_class_init(ObjectClass *oc,= void *data) arm_class_prop_set_auto_ofs, (void *)(uintptr_t)offsetof(ARMCPUClass, has_el= 2)); } + if (arm_class_feature(acc, ARM_FEATURE_EL3) || + arm_class_feature(acc, ARM_FEATURE_V8)) { + class_property_add(oc, "has_el3", "bool", NULL, + arm_class_prop_get_auto_ofs, + arm_class_prop_set_auto_ofs, + (void *)(uintptr_t)offsetof(ARMCPUClass, has_el= 3)); + } #endif /* !CONFIG_USER_ONLY */ } =20 @@ -2405,6 +2381,42 @@ static bool arm_cpu_class_late_init(ObjectClass *oc,= Error **errp) default: g_assert_not_reached(); } + + if (acc->has_el3 =3D=3D ON_OFF_AUTO_AUTO) { + if (tcg_enabled() || qtest_enabled()) { + acc->has_el3 =3D (arm_class_feature(acc, ARM_FEATURE_EL3) + ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF); + } else { + acc->has_el3 =3D ON_OFF_AUTO_OFF; + } + } + switch (acc->has_el3) { + case ON_OFF_AUTO_OFF: + unset_class_feature(acc, ARM_FEATURE_EL3); + /* + * Disable the security extension feature bits in the processor + * feature registers as well. + */ + acc->isar.id_pfr1 =3D FIELD_DP32(acc->isar.id_pfr1, ID_PFR1, SECUR= ITY, 0); + acc->isar.id_dfr0 =3D FIELD_DP32(acc->isar.id_dfr0, ID_DFR0, COPSD= BG, 0); + acc->isar.id_aa64pfr0 =3D FIELD_DP64(acc->isar.id_aa64pfr0, + ID_AA64PFR0, EL3, 0); + break; + case ON_OFF_AUTO_ON: + if (!tcg_enabled() && !qtest_enabled()) { + error_setg(errp, + "Cannot enable %s when guest CPU has EL3 enabled", + current_accel_name()); + return false; + } + if (!arm_class_feature(acc, ARM_FEATURE_EL3)) { + error_setg(errp, "CPU does not support EL3"); + return false; + } + break; + default: + g_assert_not_reached(); + } #endif /* !CONFIG_USER_ONLY */ =20 /* Run some consistency checks for TCG. */ --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770496; cv=none; d=zohomail.com; s=zohoarc; b=JhLt78wUE/HPWHQlsWWz8Euo5Pvlwmi/atkZA6VUSnzs2h0Dgc4p3q0vX2eJ0bKSkqFQ4QIEpg1lhzt+hHFrDxa4gUJNJBE1bykZXj95+KeWp4YCWjGrpNhJ+8jhX7QAAykLuKjd/Izqk8GrWmAK+6SO79KurKLsv7DQsN3LFIo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770496; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=RTwMqyhlkCLAE14wwdpweGikJKU6H9FwK5bch9gSJbk=; b=i335MetiOiSlnSl09AETKU4yqR9ZwE8FuaWk3/8WC1nv0sTNctg4ZRROMT/oIRmQLzrq2B90cSRU5/vH0Js87YxiVdwCJ03l+Pk3ANF+gGNNkLKiJZsYHMYOVv3VKVWp6/VJBrvYr1EyzmdYfTjf2gHBxOs2gMVDw/HctlzGVVw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770496233843.8274937324569; Tue, 3 Jan 2023 10:28:16 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCls4-00013h-Ld; Tue, 03 Jan 2023 13:18:44 -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 1pCls2-000119-JM for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:43 -0500 Received: from mail-qt1-x835.google.com ([2607:f8b0:4864:20::835]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pCls0-0005Oj-Ob for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:42 -0500 Received: by mail-qt1-x835.google.com with SMTP id z12so25180843qtv.5 for ; Tue, 03 Jan 2023 10:18: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.18.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:18:39 -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=RTwMqyhlkCLAE14wwdpweGikJKU6H9FwK5bch9gSJbk=; b=Kr6/wqmjMyOFMK+cIZ3rJrAxGCjuU1irdVP0/ilPhumrH4kZ9nNALIn6ds/jgmPmLJ mA8qu1P4ES3AWCIt8mssLHqBWkf/pzzaZOT1seOtZy7Ekm9zZwUPEyBmB6Hv5xYTiNX7 MbqpKF3gLlptyk+1PC+ah3om0GrJD7WrsJk1ORiMFChojAvAPEiapWeMKhZtwqPeYkXM J+DD5dtdbGjBx1l87asd7hDWH7LGW2p90Zc+gsvHwAMlkZIe+o1t9O/OOgzOOm75D6DW LvImS/cHRA1+I4Sgwfvy4Qx1g16M/aQq6u2vrkvl55raRK2EcvRyZ7B/aj0ze9aXzEif mbQA== 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=RTwMqyhlkCLAE14wwdpweGikJKU6H9FwK5bch9gSJbk=; b=dTfup/GAwxWUHpgUBVH0tRwQOu1YzhPi9m9JhfqXyd/5R7FgBt4tVnqo0XHXHPZm3p ucP3q9mHguMJUV3ZSPqy50/oSrOOJwUwdkab+jfPt8R8884qfzsvl/p61D1EbemEHF0t kISkMx/U6wwhzn/WFpMOWZA7SI2bcElg7Y6JwUcHldBWy8pRqA7+6Zcz2qcUagdDaDVS p60vMy4BPkH7EPJDyqevs64YRcJY2q4NZ+IvVjXPVhaAx8trnN1wlH288Mk44LWCmbLI YjXHDaza93iZpX+25eIZICOejIYucghy+Qf0efxbnufQoVptqiHIE/Icr86hBVMSRSGT bbhg== X-Gm-Message-State: AFqh2ko5UjFOhoZWPTpLTyWxVMZWQiB1NoDiN3bU77sX2ps6n6SS9Fgb MNLv/+Ff4i2yIJxKpd+qttyDGUzDhw8JxBVTmY4= X-Google-Smtp-Source: AMrXdXuU5MUCmBWQmURljRj9y6J/AOY4Bq3FTZ2GmOXAa/P3uEu8X48b4+OaF2I+pEIYcGT1PtXDyw== X-Received: by 2002:ac8:1382:0:b0:3a9:8b48:f8f with SMTP id h2-20020ac81382000000b003a98b480f8fmr63259237qtj.67.1672769919600; Tue, 03 Jan 2023 10:18: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 37/40] target/arm: Move "cfgend" to class property Date: Tue, 3 Jan 2023 10:16:43 -0800 Message-Id: <20230103181646.55711-38-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::835; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x835.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770498179100006 Content-Type: text/plain; charset="utf-8" Remove the cfgend variable entirely and reuse the property accessor functions created for reset-hivecs. This removes the last setting of cpu->reset_sctlr, to we can remove that as well, using only the class value. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- target/arm/cpu.h | 8 -------- target/arm/cpu.c | 26 ++++++++++++-------------- target/arm/helper.c | 4 ++-- 3 files changed, 14 insertions(+), 24 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 5921660d86..23070a9c25 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -954,7 +954,6 @@ struct ArchCPU { uint32_t revidr; uint32_t reset_fpsid; uint64_t ctr; - uint32_t reset_sctlr; uint64_t pmceid0; uint64_t pmceid1; uint32_t id_afr0; @@ -987,13 +986,6 @@ struct ArchCPU { int gic_vprebits; /* number of virtual preemption bits */ int gic_pribits; /* number of physical priority bits */ =20 - /* Whether the cfgend input is high (i.e. this CPU should reset into - * big-endian mode). This setting isn't used directly: instead it mod= ifies - * the reset_sctlr value to have SCTLR_B or SCTLR_EE set, depending on= the - * architecture version. - */ - bool cfgend; - QLIST_HEAD(, ARMELChangeHook) pre_el_change_hooks; QLIST_HEAD(, ARMELChangeHook) el_change_hooks; =20 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 3262e86e61..17d08e0e9c 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1222,7 +1222,6 @@ static void arm_cpu_initfn(Object *obj) cpu->revidr =3D acc->revidr; cpu->id_afr0 =3D acc->id_afr0; cpu->reset_fpsid =3D acc->reset_fpsid; - cpu->reset_sctlr =3D acc->reset_sctlr; cpu->reset_auxcr =3D acc->reset_auxcr; cpu->pmsav7_dregion =3D acc->pmsav7_dregion; cpu->sau_sregion =3D acc->sau_sregion; @@ -1280,9 +1279,6 @@ static void arm_cpu_initfn(Object *obj) static Property arm_cpu_reset_cbar_property =3D DEFINE_PROP_UINT64("reset-cbar", ARMCPU, reset_cbar, 0); =20 -static Property arm_cpu_cfgend_property =3D - DEFINE_PROP_BOOL("cfgend", ARMCPU, cfgend, false); - static Property arm_cpu_has_vfp_property =3D DEFINE_PROP_BOOL("vfp", ARMCPU, has_vfp, true); =20 @@ -1442,8 +1438,6 @@ static void arm_cpu_post_init(Object *obj) &cpu->psci_conduit, OBJ_PROP_FLAG_READWRITE); =20 - qdev_property_add_static(DEVICE(obj), &arm_cpu_cfgend_property); - if (kvm_enabled()) { kvm_arm_add_vcpu_properties(obj); } @@ -1771,14 +1765,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Erro= r **errp) return; } =20 - if (cpu->cfgend) { - if (arm_feature(&cpu->env, ARM_FEATURE_V7)) { - cpu->reset_sctlr |=3D SCTLR_EE; - } else { - cpu->reset_sctlr |=3D SCTLR_B; - } - } - if (!cpu->has_pmu) { unset_feature(env, ARM_FEATURE_PMU); } @@ -2306,6 +2292,18 @@ static void arm_cpu_leaf_class_init(ObjectClass *oc,= void *data) } =20 #ifndef CONFIG_USER_ONLY + /* + * When the cfgend input is high, the CPU should reset into + * big-endian mode. Modify the reset_sctlr value to have SCTLR_B + * or SCTLR_EE set, depending on the architecture version. + */ + class_property_add(oc, "cfgend", "bool", NULL, + arm_class_prop_get_sctlrbit, + arm_class_prop_set_sctlrbit, + (void *)(uintptr_t) + (arm_class_feature(acc, ARM_FEATURE_V7) + ? SCTLR_EE : SCTLR_B)); + if (arm_class_feature(acc, ARM_FEATURE_GENERIC_TIMER)) { class_property_add(oc, "cntfrq", "uint64", NULL, arm_class_prop_uint64_ofs, diff --git a/target/arm/helper.c b/target/arm/helper.c index 67d32c2e59..e414fa11dd 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -7995,7 +7995,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) .access =3D PL3_RW, .raw_writefn =3D raw_write, .writefn =3D sctlr_write, .fieldoffset =3D offsetof(CPUARMState, cp15.sctlr_el[3]), - .resetvalue =3D cpu->reset_sctlr }, + .resetvalue =3D acc->reset_sctlr }, }; =20 define_arm_cp_regs(cpu, el3_regs); @@ -8331,7 +8331,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) .access =3D PL1_RW, .accessfn =3D access_tvm_trvm, .bank_fieldoffsets =3D { offsetof(CPUARMState, cp15.sctlr_s), offsetof(CPUARMState, cp15.sctlr_ns) }, - .writefn =3D sctlr_write, .resetvalue =3D cpu->reset_sctlr, + .writefn =3D sctlr_write, .resetvalue =3D acc->reset_sctlr, .raw_writefn =3D raw_write, }; if (arm_feature(env, ARM_FEATURE_XSCALE)) { --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770148; cv=none; d=zohomail.com; s=zohoarc; b=h7kVHiqFemQewm9vrCA9U+ZWTfBZTAaZBoEE9n0g+dw/BVu9JShYSByCJRoNMO92d3YhgzGlawTVTaInkqVVtozqPmUXIy3WP6s4+xSwfEle3qdcIjZntd935aCDdgViXLfUjqop163pf0AapPkiq85vrG4tfb9I5pYVCnF8YqY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770148; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=AkaW/qtvsCW7a76sQ3IuBy/9ulOGdfXEvrcn4pt2h3o=; b=I9G+isMm+1/rlEIMJIuE1/xY0i8zGxhAm7VcfV92P6tp2hx2fvq7WAaV0v9YKZAGxaTfUrk4zCkvJy/gXIKJCZvlhR4kr7ak6fMNXsuAu5J6CNoVvnNlxrdHzrjQQUfsKHAiQIE2YXbNrsWH5lEqH0ekD0iVv568qSN1+cT7378= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770148494743.6471610032992; Tue, 3 Jan 2023 10:22:28 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pCls7-0001Cd-OT; Tue, 03 Jan 2023 13:18:47 -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 1pCls6-00017v-7n for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:46 -0500 Received: from mail-qv1-xf2e.google.com ([2607:f8b0:4864:20::f2e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pCls3-0005PE-Ku for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:45 -0500 Received: by mail-qv1-xf2e.google.com with SMTP id j9so15630918qvt.0 for ; Tue, 03 Jan 2023 10:18:43 -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.18.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:18:42 -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=AkaW/qtvsCW7a76sQ3IuBy/9ulOGdfXEvrcn4pt2h3o=; b=P7/SMwRcz8trG6lwyX//Xrq/CDgbNGm7SMpEM3zszbiNWi+DH3VRbL5qpFbSO9KNVA 7xgZ1Vx1y5ZsPcX6bzIUUB0ANuz33ZGbhuh5X0kReiIJcgoiMygl9QtfjGWMs15lkEVX lp857nXyGLh7srwBl3tghwUGItqvY7gjb2R+ya1eNX2l1WTUPZM22eEWPConSIbiEab5 4Q6FBOm50wbisMrNryhloJFnIdDduuJxm3jIf9Tw8erQvhwb85bIXBqS3uHicSF85yyD 3AN+70CAAW7IBbMcH9hpBwmLG8Bv/Ggz1m1lB15T4+so17PHWzQSO5KS/v0AJgxM+JP8 3CuQ== 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=AkaW/qtvsCW7a76sQ3IuBy/9ulOGdfXEvrcn4pt2h3o=; b=4WFHXWdnj9Y0oqaKKMBFrZOI8Hfa/niYs3JVv8a/UP3bTPWS5bDWTPVYLTCG0vmSdE uwymO5An+RlShKiZ8CmFDNWrs8GK5pz36fWNAA/vsialfdoEqVk1ApqA4nzlFJ0II3pM VQmqX0P9Aig5DqmXbGOjnboY0hILQcAfHKybClcAV90XQ12i3KqqiT0ifoYNfIBRN8ng 8I5OuAjted+w3ZTGpi92ScRn3WKEP3Q3LXmmv97hNUpU0l3eJr8g2Qu+NGnIlv90Esp/ /am6tDYd9KhF4yZKfMICQqiMro8ARl7mUT0m+AMZ6QZmSgP+4txLEHAOXywcs2TwOwGH 2MbA== X-Gm-Message-State: AFqh2kqaFse1VBkBpKsC42lqFV6hiNSVFMt5cSIEQuUd5b0mDlKuFEok rH58B5Drzl4HXdn7EfJsOz8nSfAqR3+nhYZ5vg4= X-Google-Smtp-Source: AMrXdXtuwk6gYSOp9eWxZdbQQZG7aH8eFTczAwSCaAHr0H0arKaF4H1XYSExxtLA6XVq9fEh3gLS2Q== X-Received: by 2002:a0c:fcd0:0:b0:531:8f0c:e6b0 with SMTP id i16-20020a0cfcd0000000b005318f0ce6b0mr37037877qvq.7.1672769922496; Tue, 03 Jan 2023 10:18:42 -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 38/40] target/arm: Move "vfp" and "neon" to class properties Date: Tue, 3 Jan 2023 10:16:44 -0800 Message-Id: <20230103181646.55711-39-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::f2e; envelope-from=richard.henderson@linaro.org; helo=mail-qv1-xf2e.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770149552100003 Content-Type: text/plain; charset="utf-8" With the movement of the properties, we can remove the fields from the cpu entirely, using only the class. Signed-off-by: Richard Henderson --- target/arm/cpu-qom.h | 4 + target/arm/cpu.h | 4 - hw/arm/aspeed_ast2600.c | 3 +- target/arm/cpu.c | 340 +++++++++++++++++++++------------------- 4 files changed, 186 insertions(+), 165 deletions(-) diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h index f4e01e0ddb..0e71569ab5 100644 --- a/target/arm/cpu-qom.h +++ b/target/arm/cpu-qom.h @@ -188,6 +188,10 @@ struct ARMCPUClass { OnOffAuto has_el3; /* CPU has virtualization extension */ OnOffAuto has_el2; + /* CPU has VFP */ + OnOffAuto has_vfp; + /* CPU has Neon */ + OnOffAuto has_neon; }; =20 static inline int arm_class_feature(ARMCPUClass *acc, int feature) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 23070a9c25..8d2f78b601 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -888,10 +888,6 @@ struct ArchCPU { =20 /* CPU has PMU (Performance Monitor Unit) */ bool has_pmu; - /* CPU has VFP */ - bool has_vfp; - /* CPU has Neon */ - bool has_neon; =20 /* CPU has memory protection unit */ bool has_mpu; diff --git a/hw/arm/aspeed_ast2600.c b/hw/arm/aspeed_ast2600.c index bb8579546e..de5cda2093 100644 --- a/hw/arm/aspeed_ast2600.c +++ b/hw/arm/aspeed_ast2600.c @@ -156,6 +156,7 @@ static void aspeed_soc_ast2600_init(Object *obj) =20 cpu_class =3D object_class_by_name(sc->cpu_type); class_property_set_uint(cpu_class, "cntfrq", 1125000000, &error_abort); + class_property_set_bool(cpu_class, "neon", false, &error_abort); =20 for (i =3D 0; i < sc->num_cpus; i++) { object_initialize_child(obj, "cpu[*]", &s->cpu[i], sc->cpu_type); @@ -309,8 +310,6 @@ static void aspeed_soc_ast2600_realize(DeviceState *dev= , Error **errp) object_property_set_int(OBJECT(&s->cpu[i]), "mp-affinity", aspeed_calc_affinity(i), &error_abort); =20 - object_property_set_bool(OBJECT(&s->cpu[i]), "neon", false, - &error_abort); object_property_set_link(OBJECT(&s->cpu[i]), "memory", OBJECT(s->memory), &error_abort); =20 diff --git a/target/arm/cpu.c b/target/arm/cpu.c index 17d08e0e9c..e48f62a6fc 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1279,12 +1279,6 @@ static void arm_cpu_initfn(Object *obj) static Property arm_cpu_reset_cbar_property =3D DEFINE_PROP_UINT64("reset-cbar", ARMCPU, reset_cbar, 0); =20 -static Property arm_cpu_has_vfp_property =3D - DEFINE_PROP_BOOL("vfp", ARMCPU, has_vfp, true); - -static Property arm_cpu_has_neon_property =3D - DEFINE_PROP_BOOL("neon", ARMCPU, has_neon, true); - static Property arm_cpu_has_mpu_property =3D DEFINE_PROP_BOOL("has-mpu", ARMCPU, has_mpu, true); =20 @@ -1381,27 +1375,6 @@ static void arm_cpu_post_init(Object *obj) object_property_add_bool(obj, "pmu", arm_get_pmu, arm_set_pmu); } =20 - /* - * Allow user to turn off VFP and Neon support, but only for TCG -- - * KVM does not currently allow us to lie to the guest about its - * ID/feature registers, so the guest always sees what the host has. - */ - if (arm_feature(&cpu->env, ARM_FEATURE_AARCH64) - ? cpu_isar_feature(aa64_fp_simd, cpu) - : cpu_isar_feature(aa32_vfp, cpu)) { - cpu->has_vfp =3D true; - if (!kvm_enabled() && !arm_feature(&cpu->env, ARM_FEATURE_M)) { - qdev_property_add_static(DEVICE(obj), &arm_cpu_has_vfp_propert= y); - } - } - - if (arm_feature(&cpu->env, ARM_FEATURE_NEON)) { - cpu->has_neon =3D true; - if (!kvm_enabled()) { - qdev_property_add_static(DEVICE(obj), &arm_cpu_has_neon_proper= ty); - } - } - if (arm_feature(&cpu->env, ARM_FEATURE_PMSA)) { qdev_property_add_static(DEVICE(obj), &arm_cpu_has_mpu_property); if (arm_feature(&cpu->env, ARM_FEATURE_V7)) { @@ -1603,137 +1576,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Err= or **errp) return; } =20 - if (arm_feature(env, ARM_FEATURE_AARCH64) && - cpu->has_vfp !=3D cpu->has_neon) { - /* - * This is an architectural requirement for AArch64; AArch32 is - * more flexible and permits VFP-no-Neon and Neon-no-VFP. - */ - error_setg(errp, - "AArch64 CPUs must have both VFP and Neon or neither"); - return; - } - - if (!cpu->has_vfp) { - uint64_t t; - uint32_t u; - - t =3D cpu->isar.id_aa64isar1; - t =3D FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 0); - cpu->isar.id_aa64isar1 =3D t; - - t =3D cpu->isar.id_aa64pfr0; - t =3D FIELD_DP64(t, ID_AA64PFR0, FP, 0xf); - cpu->isar.id_aa64pfr0 =3D t; - - u =3D cpu->isar.id_isar6; - u =3D FIELD_DP32(u, ID_ISAR6, JSCVT, 0); - u =3D FIELD_DP32(u, ID_ISAR6, BF16, 0); - cpu->isar.id_isar6 =3D u; - - u =3D cpu->isar.mvfr0; - u =3D FIELD_DP32(u, MVFR0, FPSP, 0); - u =3D FIELD_DP32(u, MVFR0, FPDP, 0); - u =3D FIELD_DP32(u, MVFR0, FPDIVIDE, 0); - u =3D FIELD_DP32(u, MVFR0, FPSQRT, 0); - u =3D FIELD_DP32(u, MVFR0, FPROUND, 0); - if (!arm_feature(env, ARM_FEATURE_M)) { - u =3D FIELD_DP32(u, MVFR0, FPTRAP, 0); - u =3D FIELD_DP32(u, MVFR0, FPSHVEC, 0); - } - cpu->isar.mvfr0 =3D u; - - u =3D cpu->isar.mvfr1; - u =3D FIELD_DP32(u, MVFR1, FPFTZ, 0); - u =3D FIELD_DP32(u, MVFR1, FPDNAN, 0); - u =3D FIELD_DP32(u, MVFR1, FPHP, 0); - if (arm_feature(env, ARM_FEATURE_M)) { - u =3D FIELD_DP32(u, MVFR1, FP16, 0); - } - cpu->isar.mvfr1 =3D u; - - u =3D cpu->isar.mvfr2; - u =3D FIELD_DP32(u, MVFR2, FPMISC, 0); - cpu->isar.mvfr2 =3D u; - } - - if (!cpu->has_neon) { - uint64_t t; - uint32_t u; - - unset_feature(env, ARM_FEATURE_NEON); - - t =3D cpu->isar.id_aa64isar0; - t =3D FIELD_DP64(t, ID_AA64ISAR0, AES, 0); - t =3D FIELD_DP64(t, ID_AA64ISAR0, SHA1, 0); - t =3D FIELD_DP64(t, ID_AA64ISAR0, SHA2, 0); - t =3D FIELD_DP64(t, ID_AA64ISAR0, SHA3, 0); - t =3D FIELD_DP64(t, ID_AA64ISAR0, SM3, 0); - t =3D FIELD_DP64(t, ID_AA64ISAR0, SM4, 0); - t =3D FIELD_DP64(t, ID_AA64ISAR0, DP, 0); - cpu->isar.id_aa64isar0 =3D t; - - t =3D cpu->isar.id_aa64isar1; - t =3D FIELD_DP64(t, ID_AA64ISAR1, FCMA, 0); - t =3D FIELD_DP64(t, ID_AA64ISAR1, BF16, 0); - t =3D FIELD_DP64(t, ID_AA64ISAR1, I8MM, 0); - cpu->isar.id_aa64isar1 =3D t; - - t =3D cpu->isar.id_aa64pfr0; - t =3D FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 0xf); - cpu->isar.id_aa64pfr0 =3D t; - - u =3D cpu->isar.id_isar5; - u =3D FIELD_DP32(u, ID_ISAR5, AES, 0); - u =3D FIELD_DP32(u, ID_ISAR5, SHA1, 0); - u =3D FIELD_DP32(u, ID_ISAR5, SHA2, 0); - u =3D FIELD_DP32(u, ID_ISAR5, RDM, 0); - u =3D FIELD_DP32(u, ID_ISAR5, VCMA, 0); - cpu->isar.id_isar5 =3D u; - - u =3D cpu->isar.id_isar6; - u =3D FIELD_DP32(u, ID_ISAR6, DP, 0); - u =3D FIELD_DP32(u, ID_ISAR6, FHM, 0); - u =3D FIELD_DP32(u, ID_ISAR6, BF16, 0); - u =3D FIELD_DP32(u, ID_ISAR6, I8MM, 0); - cpu->isar.id_isar6 =3D u; - - if (!arm_feature(env, ARM_FEATURE_M)) { - u =3D cpu->isar.mvfr1; - u =3D FIELD_DP32(u, MVFR1, SIMDLS, 0); - u =3D FIELD_DP32(u, MVFR1, SIMDINT, 0); - u =3D FIELD_DP32(u, MVFR1, SIMDSP, 0); - u =3D FIELD_DP32(u, MVFR1, SIMDHP, 0); - cpu->isar.mvfr1 =3D u; - - u =3D cpu->isar.mvfr2; - u =3D FIELD_DP32(u, MVFR2, SIMDMISC, 0); - cpu->isar.mvfr2 =3D u; - } - } - - if (!cpu->has_neon && !cpu->has_vfp) { - uint64_t t; - uint32_t u; - - t =3D cpu->isar.id_aa64isar0; - t =3D FIELD_DP64(t, ID_AA64ISAR0, FHM, 0); - cpu->isar.id_aa64isar0 =3D t; - - t =3D cpu->isar.id_aa64isar1; - t =3D FIELD_DP64(t, ID_AA64ISAR1, FRINTTS, 0); - cpu->isar.id_aa64isar1 =3D t; - - u =3D cpu->isar.mvfr0; - u =3D FIELD_DP32(u, MVFR0, SIMDREG, 0); - cpu->isar.mvfr0 =3D u; - - /* Despite the name, this field covers both VFP and Neon */ - u =3D cpu->isar.mvfr1; - u =3D FIELD_DP32(u, MVFR1, SIMDFMAC, 0); - cpu->isar.mvfr1 =3D u; - } - /* * We rely on no XScale CPU having VFP so we can use the same bits in = the * TB flags field for VECSTRIDE and XSCALE_CPAR. @@ -2102,7 +1944,6 @@ static bool arm_class_prop_uint64_ofs(ObjectClass *oc= , Visitor *v, return visit_type_uint64(v, name, ptr, errp); } =20 -#ifndef CONFIG_USER_ONLY static bool arm_class_prop_get_auto_ofs(ObjectClass *oc, Visitor *v, const char *name, void *opaque, Error **errp) @@ -2131,6 +1972,7 @@ static bool arm_class_prop_set_auto_ofs(ObjectClass *= oc, Visitor *v, return false; } =20 +#ifndef CONFIG_USER_ONLY static bool arm_class_prop_set_sctlrbit(ObjectClass *oc, Visitor *v, const char *name, void *opaque, Error **errp) @@ -2339,11 +2181,34 @@ static void arm_cpu_leaf_class_init(ObjectClass *oc= , void *data) (void *)(uintptr_t)offsetof(ARMCPUClass, has_el= 3)); } #endif /* !CONFIG_USER_ONLY */ + + /* + * Similarly, allow user to turn off VFP and Neon support with TCG. + * While the id registers may not yet be configured for properly + * detecting VFP for "host" or "max", we know that all aarch64 has + * support, so substitute AARCH64. Neon is always set correctly. + */ + if (arm_class_feature(acc, ARM_FEATURE_AARCH64) || + (class_isar_feature(aa32_vfp, acc) && + !arm_class_feature(acc, ARM_FEATURE_M))) { + class_property_add(oc, "vfp", "bool", NULL, + arm_class_prop_get_auto_ofs, + arm_class_prop_set_auto_ofs, + (void *)(uintptr_t)offsetof(ARMCPUClass, has_vf= p)); + } + if (arm_class_feature(acc, ARM_FEATURE_NEON)) { + class_property_add(oc, "neon", "bool", NULL, + arm_class_prop_get_auto_ofs, + arm_class_prop_set_auto_ofs, + (void *)(uintptr_t)offsetof(ARMCPUClass, has_ne= on)); + } } =20 static bool arm_cpu_class_late_init(ObjectClass *oc, Error **errp) { ARMCPUClass *acc =3D ARM_CPU_CLASS(oc); + uint64_t t; + uint32_t u; =20 if (acc->info->class_late_init) { if (!acc->info->class_late_init(acc, errp)) { @@ -2417,6 +2282,163 @@ static bool arm_cpu_class_late_init(ObjectClass *oc= , Error **errp) } #endif /* !CONFIG_USER_ONLY */ =20 + if (!arm_class_feature(acc, ARM_FEATURE_M)) { + if (acc->has_vfp =3D=3D ON_OFF_AUTO_AUTO) { + acc->has_vfp =3D ((arm_class_feature(acc, ARM_FEATURE_AARCH64) + ? class_isar_feature(aa64_fp_simd, acc) + : class_isar_feature(aa32_vfp, acc)) + ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF); + } + switch (acc->has_vfp) { + default: + g_assert_not_reached(); + case ON_OFF_AUTO_ON: + break; + case ON_OFF_AUTO_OFF: + /* + * Neither KVM nor HVF allow us to lie to the guest about + * ID/feature registers, so the guest always sees what + * the host has. + */ + if (!tcg_enabled() && !qtest_enabled()) { + error_setg(errp, + "Cannot enable %s when guest CPU has VFP disabl= ed", + current_accel_name()); + return false; + } + + t =3D acc->isar.id_aa64isar1; + t =3D FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 0); + acc->isar.id_aa64isar1 =3D t; + + t =3D acc->isar.id_aa64pfr0; + t =3D FIELD_DP64(t, ID_AA64PFR0, FP, 0xf); + acc->isar.id_aa64pfr0 =3D t; + + u =3D acc->isar.id_isar6; + u =3D FIELD_DP32(u, ID_ISAR6, JSCVT, 0); + u =3D FIELD_DP32(u, ID_ISAR6, BF16, 0); + acc->isar.id_isar6 =3D u; + + u =3D acc->isar.mvfr0; + u =3D FIELD_DP32(u, MVFR0, FPSP, 0); + u =3D FIELD_DP32(u, MVFR0, FPDP, 0); + u =3D FIELD_DP32(u, MVFR0, FPDIVIDE, 0); + u =3D FIELD_DP32(u, MVFR0, FPSQRT, 0); + u =3D FIELD_DP32(u, MVFR0, FPROUND, 0); + u =3D FIELD_DP32(u, MVFR0, FPTRAP, 0); + u =3D FIELD_DP32(u, MVFR0, FPSHVEC, 0); + acc->isar.mvfr0 =3D u; + + u =3D acc->isar.mvfr1; + u =3D FIELD_DP32(u, MVFR1, FPFTZ, 0); + u =3D FIELD_DP32(u, MVFR1, FPDNAN, 0); + u =3D FIELD_DP32(u, MVFR1, FPHP, 0); + acc->isar.mvfr1 =3D u; + + u =3D acc->isar.mvfr2; + u =3D FIELD_DP32(u, MVFR2, FPMISC, 0); + acc->isar.mvfr2 =3D u; + break; + } + + if (acc->has_neon =3D=3D ON_OFF_AUTO_AUTO) { + acc->has_neon =3D (arm_class_feature(acc, ARM_FEATURE_NEON) + ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF); + } + switch (acc->has_neon) { + default: + g_assert_not_reached(); + case ON_OFF_AUTO_ON: + break; + case ON_OFF_AUTO_OFF: + if (!tcg_enabled() && !qtest_enabled()) { + error_setg(errp, + "Cannot enable %s when guest CPU has NEON disab= led", + current_accel_name()); + return false; + } + + unset_class_feature(acc, ARM_FEATURE_NEON); + + t =3D acc->isar.id_aa64isar0; + t =3D FIELD_DP64(t, ID_AA64ISAR0, AES, 0); + t =3D FIELD_DP64(t, ID_AA64ISAR0, SHA1, 0); + t =3D FIELD_DP64(t, ID_AA64ISAR0, SHA2, 0); + t =3D FIELD_DP64(t, ID_AA64ISAR0, SHA3, 0); + t =3D FIELD_DP64(t, ID_AA64ISAR0, SM3, 0); + t =3D FIELD_DP64(t, ID_AA64ISAR0, SM4, 0); + t =3D FIELD_DP64(t, ID_AA64ISAR0, DP, 0); + acc->isar.id_aa64isar0 =3D t; + + t =3D acc->isar.id_aa64isar1; + t =3D FIELD_DP64(t, ID_AA64ISAR1, FCMA, 0); + t =3D FIELD_DP64(t, ID_AA64ISAR1, BF16, 0); + t =3D FIELD_DP64(t, ID_AA64ISAR1, I8MM, 0); + acc->isar.id_aa64isar1 =3D t; + + t =3D acc->isar.id_aa64pfr0; + t =3D FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 0xf); + acc->isar.id_aa64pfr0 =3D t; + + u =3D acc->isar.id_isar5; + u =3D FIELD_DP32(u, ID_ISAR5, AES, 0); + u =3D FIELD_DP32(u, ID_ISAR5, SHA1, 0); + u =3D FIELD_DP32(u, ID_ISAR5, SHA2, 0); + u =3D FIELD_DP32(u, ID_ISAR5, RDM, 0); + u =3D FIELD_DP32(u, ID_ISAR5, VCMA, 0); + acc->isar.id_isar5 =3D u; + + u =3D acc->isar.id_isar6; + u =3D FIELD_DP32(u, ID_ISAR6, DP, 0); + u =3D FIELD_DP32(u, ID_ISAR6, FHM, 0); + u =3D FIELD_DP32(u, ID_ISAR6, BF16, 0); + u =3D FIELD_DP32(u, ID_ISAR6, I8MM, 0); + acc->isar.id_isar6 =3D u; + + u =3D acc->isar.mvfr1; + u =3D FIELD_DP32(u, MVFR1, SIMDLS, 0); + u =3D FIELD_DP32(u, MVFR1, SIMDINT, 0); + u =3D FIELD_DP32(u, MVFR1, SIMDSP, 0); + u =3D FIELD_DP32(u, MVFR1, SIMDHP, 0); + acc->isar.mvfr1 =3D u; + + u =3D acc->isar.mvfr2; + u =3D FIELD_DP32(u, MVFR2, SIMDMISC, 0); + acc->isar.mvfr2 =3D u; + + if (acc->has_vfp =3D=3D ON_OFF_AUTO_OFF) { + t =3D acc->isar.id_aa64isar0; + t =3D FIELD_DP64(t, ID_AA64ISAR0, FHM, 0); + acc->isar.id_aa64isar0 =3D t; + + t =3D acc->isar.id_aa64isar1; + t =3D FIELD_DP64(t, ID_AA64ISAR1, FRINTTS, 0); + acc->isar.id_aa64isar1 =3D t; + + u =3D acc->isar.mvfr0; + u =3D FIELD_DP32(u, MVFR0, SIMDREG, 0); + acc->isar.mvfr0 =3D u; + + /* Despite the name, this field covers both VFP and Neon */ + u =3D acc->isar.mvfr1; + u =3D FIELD_DP32(u, MVFR1, SIMDFMAC, 0); + acc->isar.mvfr1 =3D u; + } + break; + } + if (acc->has_vfp !=3D acc->has_neon && + arm_class_feature(acc, ARM_FEATURE_AARCH64)) { + /* + * This is an architectural requirement for AArch64; AArch32 is + * more flexible and permits VFP-no-Neon and Neon-no-VFP. + */ + error_setg(errp, + "AArch64 CPUs must have both VFP and Neon or neithe= r"); + return false; + } + } + /* Run some consistency checks for TCG. */ if (tcg_enabled()) { bool no_aa32 =3D arm_class_feature(acc, ARM_FEATURE_AARCH64) && --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770123; cv=none; d=zohomail.com; s=zohoarc; b=BY/WPVYMC5r8JdLHc9HSUjmcSCwzEj5cBN9ya79gmNAfMzkz8EX+xfzDXdQbJG9zkNHCj5ygcPfxYdlINs2Jc8eXlGhjEcHxqwYav7xrh4YnsCvXbeVJHN2tZH5LszanUb7RQlcsb3adAMpF42gvQSvN8p3U2yqQt5e8IXsoiI4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770123; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XGZyyVJrORAvKbSeUKRUPp59hPckNE/NE/CsroPLC8I=; b=mPZbEEkJy5M8sXTcMtX/WEXdXX/SHIagHV56NcYortu/bGB7Ox5CrThil7io4n9KDVO9NjoxL1iN+cISRxUGaFlfrvCSEnG/FU/XGLu/khY9daDT94sVBpicdkQw9t7Zyg4aycFxB0qaWM4RzYkMS97RVR9Vkykw1HOnaD2dkFg= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770123805490.1815505035156; Tue, 3 Jan 2023 10:22:03 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClsA-0001J0-5W; Tue, 03 Jan 2023 13:18:50 -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 1pCls8-0001ER-EA for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:48 -0500 Received: from mail-qt1-x82d.google.com ([2607:f8b0:4864:20::82d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pCls6-0005PZ-Ev for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:18:48 -0500 Received: by mail-qt1-x82d.google.com with SMTP id h21so25144672qta.12 for ; Tue, 03 Jan 2023 10:18:46 -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.18.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:18:44 -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=XGZyyVJrORAvKbSeUKRUPp59hPckNE/NE/CsroPLC8I=; b=NHdHvaU7cg6ADgfUMSqL7Wufc7pZP03nykMBJ9xVriepX1f33rUqc46D/u75EOYxSY gPhPG1EUmdtPfcVRRAGJSQwN+/HQdBpUkwQYEzcX3WKeXkasgD4OyUIsHsOGjy50JNYc ALLGncTt66v18D5DBboIEktqmHm4ZMR+ha8jiTEVB8TBQd7LKEKm3IBltJb92kQjU9Oi v0tfeHa4IPZaNJlZbdNZQNuIjQU1Ju+lWi7eVEDrJWcllfuX6dTotmaDLfziY94kEljC rEwNuIWQv59VxETU2ttkva55t9B6+2mwaJb7kWjqREcMRiL1wIc37+jRaDasZ7iRGO4y MNfA== 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=XGZyyVJrORAvKbSeUKRUPp59hPckNE/NE/CsroPLC8I=; b=IDA//vVpONJ6YqSq1aFBC/bDyMLEUtlf8TnlZcw9PWyEBV/jjsDwr1oCz7ok/LHHd1 4YhpWNDrJD1hknW5gJ/iPbSd4FI/yWTZ16Nsb6ChTENVP5cCZCLObY5SGPu0SOpgN0L2 S4K4pjUufJ/QZiGT/VER1XT2eKaCSZRKMQ+4OO1oP2jB3778As7g9ARsehvxUpNf/NEF jcElrNcyvLs3wVzlzGg4Qbh94IfiWJsRQl1GEcJdx41c1NkRs7JF1OUuZJmnUm16l5ve QRJRpfkvGnW+yFnKRFlTW3S5n2uXhP6z96WvyIB8f5520bxgJJR4Ba+D9+jWSRhwRNwo 7kTA== X-Gm-Message-State: AFqh2kpEXFiLIYWQMzK0ZrdiBsW39KIYJS4iIHlxM8r+A4paEK2c8sYB MQziykX1NRul0c9tMiMw65n59AqA6ubGtM5fKrk= X-Google-Smtp-Source: AMrXdXtTW8RU7pZZs7OjtgjAZ9BsRtWxWxZz0yyGtZGe0WSmOl1eSRD5Is+C6AkfOvV2ww98TC31CA== X-Received: by 2002:a05:622a:4c0f:b0:3ab:8975:ad89 with SMTP id ey15-20020a05622a4c0f00b003ab8975ad89mr46381625qtb.60.1672769925314; Tue, 03 Jan 2023 10:18:45 -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 39/40] target/arm: Move "has-mpu" and "pmsav7-dregion" to class properties Date: Tue, 3 Jan 2023 10:16:45 -0800 Message-Id: <20230103181646.55711-40-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::82d; envelope-from=richard.henderson@linaro.org; helo=mail-qt1-x82d.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770125430100003 Content-Type: text/plain; charset="utf-8" With the movement of the properties, we can remove the has_mpu field from the cpu entirely, using only the class. The pmsav7_dregion field must stay in the cpu to handle the usage with VMSTATE_VARRAY_UINT32. Signed-off-by: Richard Henderson --- target/arm/cpu-qom.h | 3 ++ target/arm/cpu.h | 2 - target/arm/cpu.c | 117 ++++++++++++++++++++++++------------------- target/arm/helper.c | 3 +- 4 files changed, 71 insertions(+), 54 deletions(-) diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h index 0e71569ab5..8f266baa26 100644 --- a/target/arm/cpu-qom.h +++ b/target/arm/cpu-qom.h @@ -192,6 +192,9 @@ struct ARMCPUClass { OnOffAuto has_vfp; /* CPU has Neon */ OnOffAuto has_neon; + + /* CPU has memory protection unit */ + bool has_mpu; }; =20 static inline int arm_class_feature(ARMCPUClass *acc, int feature) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 8d2f78b601..1b181ecde4 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -889,8 +889,6 @@ struct ArchCPU { /* CPU has PMU (Performance Monitor Unit) */ bool has_pmu; =20 - /* CPU has memory protection unit */ - bool has_mpu; /* PMSAv7 MPU number of supported regions */ uint32_t pmsav7_dregion; /* v8M SAU number of supported regions */ diff --git a/target/arm/cpu.c b/target/arm/cpu.c index e48f62a6fc..b984735793 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1279,19 +1279,6 @@ static void arm_cpu_initfn(Object *obj) static Property arm_cpu_reset_cbar_property =3D DEFINE_PROP_UINT64("reset-cbar", ARMCPU, reset_cbar, 0); =20 -static Property arm_cpu_has_mpu_property =3D - DEFINE_PROP_BOOL("has-mpu", ARMCPU, has_mpu, true); - -/* This is like DEFINE_PROP_UINT32 but it doesn't set the default value, - * because the CPU initfn will have already set cpu->pmsav7_dregion to - * the right value for that particular CPU type, and we don't want - * to override that with an incorrect constant value. - */ -static Property arm_cpu_pmsav7_dregion_property =3D - DEFINE_PROP_UNSIGNED_NODEFAULT("pmsav7-dregion", ARMCPU, - pmsav7_dregion, - qdev_prop_uint32, uint32_t); - static bool arm_get_pmu(Object *obj, Error **errp) { ARMCPU *cpu =3D ARM_CPU(obj); @@ -1375,14 +1362,6 @@ static void arm_cpu_post_init(Object *obj) object_property_add_bool(obj, "pmu", arm_get_pmu, arm_set_pmu); } =20 - if (arm_feature(&cpu->env, ARM_FEATURE_PMSA)) { - qdev_property_add_static(DEVICE(obj), &arm_cpu_has_mpu_property); - if (arm_feature(&cpu->env, ARM_FEATURE_V7)) { - qdev_property_add_static(DEVICE(obj), - &arm_cpu_pmsav7_dregion_property); - } - } - if (arm_feature(&cpu->env, ARM_FEATURE_M_SECURITY)) { object_property_add_link(obj, "idau", TYPE_IDAU_INTERFACE, &cpu->i= dau, qdev_prop_allow_set_link_before_realize, @@ -1663,39 +1642,21 @@ static void arm_cpu_realizefn(DeviceState *dev, Err= or **errp) FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, PMSVER, 0); } =20 - /* MPU can be configured out of a PMSA CPU either by setting has-mpu - * to false or by setting pmsav7-dregion to 0. - */ - if (!cpu->has_mpu) { - cpu->pmsav7_dregion =3D 0; - } - if (cpu->pmsav7_dregion =3D=3D 0) { - cpu->has_mpu =3D false; - } - - if (arm_feature(env, ARM_FEATURE_PMSA) && - arm_feature(env, ARM_FEATURE_V7)) { + if (cpu->pmsav7_dregion) { uint32_t nr =3D cpu->pmsav7_dregion; =20 - if (nr > 0xff) { - error_setg(errp, "PMSAv7 MPU #regions invalid %" PRIu32, nr); - return; - } - - if (nr) { - if (arm_feature(env, ARM_FEATURE_V8)) { - /* PMSAv8 */ - env->pmsav8.rbar[M_REG_NS] =3D g_new0(uint32_t, nr); - env->pmsav8.rlar[M_REG_NS] =3D g_new0(uint32_t, nr); - if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { - env->pmsav8.rbar[M_REG_S] =3D g_new0(uint32_t, nr); - env->pmsav8.rlar[M_REG_S] =3D g_new0(uint32_t, nr); - } - } else { - env->pmsav7.drbar =3D g_new0(uint32_t, nr); - env->pmsav7.drsr =3D g_new0(uint32_t, nr); - env->pmsav7.dracr =3D g_new0(uint32_t, nr); + if (arm_feature(env, ARM_FEATURE_V8)) { + /* PMSAv8 */ + env->pmsav8.rbar[M_REG_NS] =3D g_new0(uint32_t, nr); + env->pmsav8.rlar[M_REG_NS] =3D g_new0(uint32_t, nr); + if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { + env->pmsav8.rbar[M_REG_S] =3D g_new0(uint32_t, nr); + env->pmsav8.rlar[M_REG_S] =3D g_new0(uint32_t, nr); } + } else { + env->pmsav7.drbar =3D g_new0(uint32_t, nr); + env->pmsav7.drsr =3D g_new0(uint32_t, nr); + env->pmsav7.dracr =3D g_new0(uint32_t, nr); } } =20 @@ -1933,6 +1894,28 @@ static const struct TCGCPUOps arm_tcg_ops =3D { }; #endif /* CONFIG_TCG */ =20 +static bool arm_class_prop_bool_ofs(ObjectClass *oc, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + ARMCPUClass *acc =3D ARM_CPU_CLASS(oc); + uintptr_t ofs =3D (uintptr_t)opaque; + bool *ptr =3D (void *)acc + ofs; + + return visit_type_bool(v, name, ptr, errp); +} + +static bool arm_class_prop_uint32_ofs(ObjectClass *oc, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + ARMCPUClass *acc =3D ARM_CPU_CLASS(oc); + uintptr_t ofs =3D (uintptr_t)opaque; + uint32_t *ptr =3D (void *)acc + ofs; + + return visit_type_uint32(v, name, ptr, errp); +} + static bool arm_class_prop_uint64_ofs(ObjectClass *oc, Visitor *v, const char *name, void *opaque, Error **errp) @@ -2202,6 +2185,22 @@ static void arm_cpu_leaf_class_init(ObjectClass *oc,= void *data) arm_class_prop_set_auto_ofs, (void *)(uintptr_t)offsetof(ARMCPUClass, has_ne= on)); } + + if (arm_class_feature(acc, ARM_FEATURE_PMSA)) { + acc->has_mpu =3D true; + class_property_add(oc, "has-mpu", "bool", NULL, + arm_class_prop_bool_ofs, + arm_class_prop_bool_ofs, + (void *)(uintptr_t)offsetof(ARMCPUClass, has_mp= u)); + + if (arm_class_feature(acc, ARM_FEATURE_V7)) { + class_property_add(oc, "pmsav7-dregion", "uint32", NULL, + arm_class_prop_uint32_ofs, + arm_class_prop_uint32_ofs, + (void *)(uintptr_t) + offsetof(ARMCPUClass, pmsav7_dregion)); + } + } } =20 static bool arm_cpu_class_late_init(ObjectClass *oc, Error **errp) @@ -2439,6 +2438,22 @@ static bool arm_cpu_class_late_init(ObjectClass *oc,= Error **errp) } } =20 + /* + * MPU can be configured out of a PMSA CPU either by setting has-mpu + * to false or by setting pmsav7-dregion to 0. + */ + if (!acc->has_mpu) { + acc->pmsav7_dregion =3D 0; + } + if (acc->pmsav7_dregion =3D=3D 0) { + acc->has_mpu =3D false; + } + if (acc->pmsav7_dregion > 0xff) { + error_setg(errp, "PMSAv7 MPU #regions invalid %" PRIu32, + acc->pmsav7_dregion); + return false; + } + /* Run some consistency checks for TCG. */ if (tcg_enabled()) { bool no_aa32 =3D arm_class_feature(acc, ARM_FEATURE_AARCH64) && diff --git a/target/arm/helper.c b/target/arm/helper.c index e414fa11dd..90f49108f8 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -4804,8 +4804,9 @@ static void sctlr_write(CPUARMState *env, const ARMCP= RegInfo *ri, uint64_t value) { ARMCPU *cpu =3D env_archcpu(env); + ARMCPUClass *acc =3D ARM_CPU_GET_CLASS(cpu); =20 - if (arm_feature(env, ARM_FEATURE_PMSA) && !cpu->has_mpu) { + if (arm_feature(env, ARM_FEATURE_PMSA) && !acc->has_mpu) { /* M bit is RAZ/WI for PMSA with no MPU implemented */ value &=3D ~SCTLR_M; } --=20 2.34.1 From nobody Wed May 15 22:39:55 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1672770507; cv=none; d=zohomail.com; s=zohoarc; b=UpgCArqdv4JAdFkDWEY6daD4kYOiPVMAh2trRxk702EcwpvSK9W305qvj/KT2w8inTMRrksCxohJLP6MRhpVAMuwFfkK1kW2cczJAd3615rHhHieAjVkN4edUADrRPqhs6oeXn9tsHzCqNrwCXBESbZ1jBKJIYHR/3L8nHrbc+k= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1672770507; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=XMnuA3U8qCvAAKV0fJRhlFvw2qzRYQPSD0W9z7bDfCw=; b=VnK44KbUxEyT27OH7s8Zyfkao8lMTD/dFa+j+siRjnAQuWJVNo3+mVeGKQ9HED8I7DrNy5KQ8ewBdUg18iTzmuDXzpeCN2W1n9HFhGV/HCyHw9hjGzCFV8IqPLcn6YfG1G7f64Xm4NljdkLfBmUwf95/FuuTwH3HJNiv7DZi5j8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1672770507213991.2413558535184; Tue, 3 Jan 2023 10:28:27 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClv9-0007Cl-7T; Tue, 03 Jan 2023 13:21:55 -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 1pClv8-00078v-53 for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:21:54 -0500 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClv5-00069D-3J for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:21:53 -0500 Received: by mail-pl1-x632.google.com with SMTP id 17so33540060pll.0 for ; Tue, 03 Jan 2023 10:21:49 -0800 (PST) Received: from stoup.. ([2607:fb90:8060:51a2:184b:6e49:c396:be2]) by smtp.gmail.com with ESMTPSA id f31-20020a17090a702200b00226463cd239sm7090698pjk.15.2023.01.03.10.21.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:21:48 -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=XMnuA3U8qCvAAKV0fJRhlFvw2qzRYQPSD0W9z7bDfCw=; b=rf/6yAwyaIV9ejbFdL/RU7e0AwbhG4YprvfZ5feDR44T4XA85xPV8zmPXEy1UMYweS XwUrcCDK68VUqGon442qCYhstJdmOjSKMXp9wkoUbs3PIGr8RzMR9L5Mg+kBDBxsmqvR p3rgdPp6DPbUiEYlPiN8NDUwaJ+qG6bETMyNQQkYq/a8dzEmD/01R5vSo5mWeINbeveW BYx98DNq9HObpVz43L5ZzjXCTN2muDBUdnrk/7JgRMf+/8GZdvBJHDlHw2OcPHBHr4If GhPFmFQ1xublWqd5vTT6e/000177rticd9jqkn2j4VM1qysJJRjN8jkxQDlogyQQ3uX6 nG5g== 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=XMnuA3U8qCvAAKV0fJRhlFvw2qzRYQPSD0W9z7bDfCw=; b=OTuTFRaz+OjgdCJq+p5Z0v9977pyOaAZKz2x4L/M5uM3cF0fKdGYamPhv2Cnx2CWpj N2UKslwlVBmrtwbpgP60JAnwcsHjKSW7/Yrs2gJsiaYfIyGmdqq4p4z+hKeBHeo4Inxh BTcVWS76UMn6gLEth52n5Vm6HEbRtm5l1lONTrdo67+wZ49tI47TvzHbvfoZRovlyuNy vr797NzRUhClfDlUrp22Uu26JWCkW0GThIxAPy0FxssmktGeg2pMraNNEsIKgrN5EYCQ FpaSW6c1Iaj5dxkMNRXIUUf6DC0AfJwo+rYeU4Aq8R/fcCb+UhnVIPY+lJhouX6uF6MQ 0Szg== X-Gm-Message-State: AFqh2krZYa6/X79uzlkOay5tE/RWeL+pG7EGRZQ08vzW1E+9BMpKfVCK 8/WwBbPUQWt5tsOzNSDoABQF3KIQTv5U4e/XpX8= X-Google-Smtp-Source: AMrXdXtJe9M7J3gyj7iVB6nDCjeXoepMIutI1BkUjqE3aoifyjjmwZtKz+VzhczMqFSdXGX8+W491A== X-Received: by 2002:a17:90a:d793:b0:219:1b52:859a with SMTP id z19-20020a17090ad79300b002191b52859amr48392950pju.10.1672770108788; Tue, 03 Jan 2023 10:21:48 -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 40/40] target/arm: Move "pmu" to class property Date: Tue, 3 Jan 2023 10:16:46 -0800 Message-Id: <20230103181646.55711-41-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 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2607:f8b0:4864:20::632; envelope-from=richard.henderson@linaro.org; helo=mail-pl1-x632.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+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1672770508299100002 Content-Type: text/plain; charset="utf-8" With the movement of the property, we can remove the field from the cpu entirely, using only the class. Properly detect support in kvm_arm_get_host_cpu_features rather than adjust much later in kvm_arch_init_vcpu. Signed-off-by: Richard Henderson --- target/arm/cpu-qom.h | 2 ++ target/arm/cpu.h | 3 --- target/arm/kvm_arm.h | 13 ---------- hw/arm/virt.c | 12 +++++----- target/arm/cpu.c | 57 ++++++++++++++++++++------------------------ target/arm/kvm.c | 24 +++++++++++-------- 6 files changed, 48 insertions(+), 63 deletions(-) diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h index 8f266baa26..0272e61c21 100644 --- a/target/arm/cpu-qom.h +++ b/target/arm/cpu-qom.h @@ -192,6 +192,8 @@ struct ARMCPUClass { OnOffAuto has_vfp; /* CPU has Neon */ OnOffAuto has_neon; + /* CPU has PMU (Performance Monitor Unit) */ + OnOffAuto has_pmu; =20 /* CPU has memory protection unit */ bool has_mpu; diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 1b181ecde4..dac72045d1 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -886,9 +886,6 @@ struct ArchCPU { /* Current power state, access guarded by BQL */ ARMPSCIState power_state; =20 - /* CPU has PMU (Performance Monitor Unit) */ - bool has_pmu; - /* PMSAv7 MPU number of supported regions */ uint32_t pmsav7_dregion; /* v8M SAU number of supported regions */ diff --git a/target/arm/kvm_arm.h b/target/arm/kvm_arm.h index d426e24c53..a958e071c1 100644 --- a/target/arm/kvm_arm.h +++ b/target/arm/kvm_arm.h @@ -177,14 +177,6 @@ void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **= errp); */ bool kvm_arm_aarch32_supported(void); =20 -/** - * kvm_arm_pmu_supported: - * - * Returns: true if KVM can enable the PMU - * and false otherwise. - */ -bool kvm_arm_pmu_supported(void); - /** * kvm_arm_sve_supported: * @@ -229,11 +221,6 @@ static inline bool kvm_arm_aarch32_supported(void) return false; } =20 -static inline bool kvm_arm_pmu_supported(void) -{ - return false; -} - static inline bool kvm_arm_sve_supported(void) { return false; diff --git a/hw/arm/virt.c b/hw/arm/virt.c index c1cabe2413..38f89559ed 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -605,7 +605,6 @@ static void fdt_add_pmu_nodes(const VirtMachineState *v= ms) MachineState *ms =3D MACHINE(vms); =20 if (!arm_feature(&armcpu->env, ARM_FEATURE_PMU)) { - assert(!object_property_get_bool(OBJECT(armcpu), "pmu", NULL)); return; } =20 @@ -1951,9 +1950,11 @@ static void virt_cpu_post_init(VirtMachineState *vms= , MemoryRegion *sysmem) int max_cpus =3D MACHINE(vms)->smp.max_cpus; bool aarch64, pmu, steal_time; CPUState *cpu; + ObjectClass *cpu_class; =20 + cpu_class =3D object_get_class(OBJECT(first_cpu)); aarch64 =3D object_property_get_bool(OBJECT(first_cpu), "aarch64", NUL= L); - pmu =3D object_property_get_bool(OBJECT(first_cpu), "pmu", NULL); + pmu =3D class_property_get_bool(cpu_class, "pmu", NULL); steal_time =3D object_property_get_bool(OBJECT(first_cpu), "kvm-steal-time", NULL); =20 @@ -2043,6 +2044,9 @@ static void machvirt_init(MachineState *machine) if (!vms->virt) { class_property_set_bool(cpu_class, "has_el2", false, &error_abort); } + if (vmc->no_pmu) { + class_property_set_bool(cpu_class, "pmu", false, &error_abort); + } =20 /* * In accelerated mode, the memory map is computed earlier in kvm_type= () @@ -2185,10 +2189,6 @@ static void machvirt_init(MachineState *machine) object_property_set_bool(cpuobj, "kvm-steal-time", false, NULL= ); } =20 - if (vmc->no_pmu && object_property_find(cpuobj, "pmu")) { - object_property_set_bool(cpuobj, "pmu", false, NULL); - } - if (vmc->no_tcg_lpa2 && object_property_find(cpuobj, "lpa2")) { object_property_set_bool(cpuobj, "lpa2", false, NULL); } diff --git a/target/arm/cpu.c b/target/arm/cpu.c index b984735793..c287b0bc89 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1279,29 +1279,6 @@ static void arm_cpu_initfn(Object *obj) static Property arm_cpu_reset_cbar_property =3D DEFINE_PROP_UINT64("reset-cbar", ARMCPU, reset_cbar, 0); =20 -static bool arm_get_pmu(Object *obj, Error **errp) -{ - ARMCPU *cpu =3D ARM_CPU(obj); - - return cpu->has_pmu; -} - -static void arm_set_pmu(Object *obj, bool value, Error **errp) -{ - ARMCPU *cpu =3D ARM_CPU(obj); - - if (value) { - if (kvm_enabled() && !kvm_arm_pmu_supported()) { - error_setg(errp, "'pmu' feature not supported by KVM on this h= ost"); - return; - } - set_feature(&cpu->env, ARM_FEATURE_PMU); - } else { - unset_feature(&cpu->env, ARM_FEATURE_PMU); - } - cpu->has_pmu =3D value; -} - unsigned int gt_cntfrq_period_ns(ARMCPU *cpu) { ARMCPUClass *acc =3D ARM_CPU_GET_CLASS(cpu); @@ -1357,11 +1334,6 @@ static void arm_cpu_post_init(Object *obj) } #endif =20 - if (arm_feature(&cpu->env, ARM_FEATURE_PMU)) { - cpu->has_pmu =3D true; - object_property_add_bool(obj, "pmu", arm_get_pmu, arm_set_pmu); - } - if (arm_feature(&cpu->env, ARM_FEATURE_M_SECURITY)) { object_property_add_link(obj, "idau", TYPE_IDAU_INTERFACE, &cpu->i= dau, qdev_prop_allow_set_link_before_realize, @@ -1586,9 +1558,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Error= **errp) return; } =20 - if (!cpu->has_pmu) { - unset_feature(env, ARM_FEATURE_PMU); - } if (arm_feature(env, ARM_FEATURE_PMU)) { pmu_init(cpu); =20 @@ -2163,6 +2132,13 @@ static void arm_cpu_leaf_class_init(ObjectClass *oc,= void *data) arm_class_prop_set_auto_ofs, (void *)(uintptr_t)offsetof(ARMCPUClass, has_el= 3)); } + + if (arm_class_feature(acc, ARM_FEATURE_PMU)) { + class_property_add(oc, "pmu", "bool", NULL, + arm_class_prop_get_auto_ofs, + arm_class_prop_set_auto_ofs, + (void *)(uintptr_t)offsetof(ARMCPUClass, has_pm= u)); + } #endif /* !CONFIG_USER_ONLY */ =20 /* @@ -2279,6 +2255,25 @@ static bool arm_cpu_class_late_init(ObjectClass *oc,= Error **errp) default: g_assert_not_reached(); } + + switch (acc->has_pmu) { + case ON_OFF_AUTO_AUTO: + acc->has_pmu =3D (arm_class_feature(acc, ARM_FEATURE_PMU) + ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF); + break; + case ON_OFF_AUTO_OFF: + unset_class_feature(acc, ARM_FEATURE_PMU); + break; + case ON_OFF_AUTO_ON: + if (!arm_class_feature(acc, ARM_FEATURE_PMU)) { + error_setg(errp, "'pmu' feature not supported by %s on this ho= st", + current_accel_name()); + return false; + } + break; + default: + g_assert_not_reached(); + } #endif /* !CONFIG_USER_ONLY */ =20 if (!arm_class_feature(acc, ARM_FEATURE_M)) { diff --git a/target/arm/kvm.c b/target/arm/kvm.c index 85971df07c..0ae435addd 100644 --- a/target/arm/kvm.c +++ b/target/arm/kvm.c @@ -239,7 +239,13 @@ void kvm_arm_add_vcpu_properties(Object *obj) "Set off to disable KVM steal time."); } =20 -bool kvm_arm_pmu_supported(void) +/** + * kvm_arm_pmu_supported: + * + * Returns: true if KVM can enable the PMU + * and false otherwise. + */ +static bool kvm_arm_pmu_supported(void) { return kvm_check_extension(kvm_state, KVM_CAP_ARM_PMU_V3); } @@ -1463,7 +1469,7 @@ void kvm_arm_pmu_init(CPUState *cs) .attr =3D KVM_ARM_VCPU_PMU_V3_INIT, }; =20 - if (!ARM_CPU(cs)->has_pmu) { + if (!arm_feature(&ARM_CPU(cs)->env, ARM_FEATURE_PMU)) { return; } if (!kvm_arm_set_device_attr(cs, &attr, "PMU")) { @@ -1480,7 +1486,7 @@ void kvm_arm_pmu_set_irq(CPUState *cs, int irq) .attr =3D KVM_ARM_VCPU_PMU_V3_IRQ, }; =20 - if (!ARM_CPU(cs)->has_pmu) { + if (!arm_feature(&ARM_CPU(cs)->env, ARM_FEATURE_PMU)) { return; } if (!kvm_arm_set_device_attr(cs, &attr, "PMU")) { @@ -1594,6 +1600,9 @@ bool kvm_arm_get_host_cpu_features(ARMCPUClass *acc, = Error **errp) if (kvm_arm_pmu_supported()) { init.features[0] |=3D 1 << KVM_ARM_VCPU_PMU_V3; pmu_supported =3D true; + } else { + /* This was optimistically set in aarch64_host_class_init. */ + unset_class_feature(acc, ARM_FEATURE_PMU); } =20 if (!kvm_arm_create_scratch_host_vcpu(cpus_to_try, fdarray, &init)) { @@ -1877,7 +1886,6 @@ int kvm_arch_init_vcpu(CPUState *cs) { int ret; ARMCPU *cpu =3D ARM_CPU(cs); - CPUARMState *env =3D &cpu->env; uint64_t psciver; =20 if (cpu->kvm_target =3D=3D QEMU_KVM_ARM_TARGET_NONE || @@ -1900,13 +1908,9 @@ int kvm_arch_init_vcpu(CPUState *cs) if (!arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { cpu->kvm_init_features[0] |=3D 1 << KVM_ARM_VCPU_EL1_32BIT; } - if (!kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PMU_V3)) { - cpu->has_pmu =3D false; - } - if (cpu->has_pmu) { + if (arm_feature(&cpu->env, ARM_FEATURE_PMU)) { + assert(kvm_arm_pmu_supported()); cpu->kvm_init_features[0] |=3D 1 << KVM_ARM_VCPU_PMU_V3; - } else { - env->features &=3D ~(1ULL << ARM_FEATURE_PMU); } if (cpu_isar_feature(aa64_sve, cpu)) { assert(kvm_arm_sve_supported()); --=20 2.34.1