From patchwork Tue Jan 3 18:16:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638759 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1394457pvb; Tue, 3 Jan 2023 10:28:19 -0800 (PST) X-Google-Smtp-Source: AMrXdXua36NyX14ekd93KWfdo6XTk1FF+w4GNaVQ1L/9hLNohUqxQRVr2DO9KrusOgpRbrq9Pw5v X-Received: by 2002:a0c:e506:0:b0:531:968c:c234 with SMTP id l6-20020a0ce506000000b00531968cc234mr39590070qvm.7.1672770499150; Tue, 03 Jan 2023 10:28:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770499; cv=none; d=google.com; s=arc-20160816; b=jC3hS+vlQ8RDcdlMqrTtxw01kih9rAk4zsudw2EWdhOKKC4FXpUACNHo0lTYMSWV8/ 3VlXGD5H1GeeoVf9LCKVsNX2hY1/ZUpvDkE31687z4D1pO8HXLLt/AaF+I/shKWDfkpI LrdO8XpmEWhpUAuiSoSb0TGAuLTvS4yw2Lm0gwc3fB4yuvVQrCuAfv38qx6P9SMmXn9h JmBogoRoQPddG0LkShTQgdZ0U1R9d/0jjxlLrVMBPUeaNwYlQ9B8rC3/LKnx1udM071P 6MoNKP0+kb8Vadx+KbooNvnJHEIgDie3pq+zYwDhu0nFmBfyZfHO0bATDwp16K9k4FyC BuCw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jTR0azPO570PZCFggyVak8jaWAO6whlTR6a7W48WgFQ=; b=dHeFhdgFnW4+ZeHivjlClpjWncOw2TzgB/B9cVg7wxXpbu97v79lqIxw3v6A2gOXm/ K0hSIba7FrJ3zJ2FZSw1n7y1DoEObF5cCcwNXKtIbyt/wM+SEq6sGJXcbmzq9tP7FIVj n8K3T/Ax2KbBe4/nkAhBe5nNryjaIRi6mP/dpZLYgvtZaa1H3o7bWBUEhKvy7vTWElah oFjRfSYvoECGooJ3O9hO4Idke+qv2MKY+zCoALW4ImwW5JN5uuwmv5fChrwRPYPR2iN6 jiB33olPGHWXxoBmy8YhdP4QdM4Mi6W0Asw1Ns3DRO/L8vFuRrKgrVspALtNhXIQIbeg 6S/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="L1/y+7Ag"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d191-20020a3768c8000000b006cf592faf2bsi16277631qkc.345.2023.01.03.10.28.19 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:28:19 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="L1/y+7Ag"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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); } -static GPtrArray *global_props(void) -{ - static GPtrArray *gp; - - if (!gp) { - gp = g_ptr_array_new(); - } - - return gp; -} +static GPtrArray *global_properties; void qdev_prop_register_global(GlobalProperty *prop) { - g_ptr_array_add(global_props(), prop); + GPtrArray *props = global_properties; + + if (!props) { + props = g_ptr_array_new(); + global_properties = props; + } + + g_ptr_array_add(props, prop); } const GlobalProperty *qdev_find_global_prop(Object *obj, const char *name) { - GPtrArray *props = global_props(); + GPtrArray *props = global_properties; const GlobalProperty *p; int i; + if (!props) { + return NULL; + } + for (i = 0; i < props->len; i++) { p = g_ptr_array_index(props, i); if (object_dynamic_cast(obj, p->driver) @@ -774,14 +776,19 @@ const GlobalProperty *qdev_find_global_prop(Object *obj, int qdev_prop_check_globals(void) { + GPtrArray *props = global_properties; int i, ret = 0; - for (i = 0; i < global_props()->len; i++) { + if (!props) { + return 0; + } + + for (i = 0; i < props->len; i++) { GlobalProperty *prop; ObjectClass *oc; DeviceClass *dc; - prop = g_ptr_array_index(global_props(), i); + prop = g_ptr_array_index(props, i); if (prop->used) { continue; } @@ -806,8 +813,12 @@ int qdev_prop_check_globals(void) void qdev_prop_set_globals(DeviceState *dev) { - object_apply_global_props(OBJECT(dev), global_props(), - dev->hotplugged ? NULL : &error_fatal); + GPtrArray *props = global_properties; + + if (props) { + object_apply_global_props(OBJECT(dev), props, + dev->hotplugged ? NULL : &error_fatal); + } } /* --- 64bit unsigned int 'size' type --- */ From patchwork Tue Jan 3 18:16:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638730 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1390915pvb; Tue, 3 Jan 2023 10:19:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXtvLrqFLICvtHQh9VA71LOHAqrBUzG2kx+fWracuBkW/MaBr8xADG7b9/w+OEKW/4zmVBFN X-Received: by 2002:ac8:7386:0:b0:3a8:fd7:7347 with SMTP id t6-20020ac87386000000b003a80fd77347mr64732002qtp.32.1672769942868; Tue, 03 Jan 2023 10:19:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672769942; cv=none; d=google.com; s=arc-20160816; b=vqJ214++nLEsw6VcrnMx98VElxf9N8/2G9RBdvZqACFucWlk2pLyJgOSWhOk3JujXQ /y0YFmtaZ/2a62xVQyip2wl0sNfd8iTrBwBvtVmsnO1gABlykP7wfC8RCsKy2G0Z6Zxc NXPuSUYdo+N1aAnBzH7RKfUhg52/4frphupoX6RBKhWvVJknpUpeJung9Evi3Rd/tQK+ 3ffkouUHtVUJr5RJ4i3sxPaX4nPlWTSXwLJiVnEtiyotk0EpbNXf1heXnKld6Qv2qkRJ Y45rxJFurg77GRncU5zaPcD/GbexS7oeEngNohHuX0DNpnGUmwn9yvRjhygCucYyriQ+ rIVw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=J7OuKp2SIiYS9GaSHXxTFNZ32lT6tsgO1dGcaZ2HR4g=; b=YVjaF/MSKZwd4Uv59lT8X+2m7MqwrzPmBerqm4xoATLHzJcB1/FEQz7uha/jyyPT5Z izihH3ePD6WNWHZ5tl01+hluIiM34ADRbK9Z3gmj/+nMll/Mu/KvQjfOme9qvDkMCOky HvdsI0cF8HNO6a6ZYqyElWO5zz347HeNTF4HfHqO4T6/MMXUd+S98vlxhU+03OrQ3V+Z h7iHoiSyHidu3ok2SuMHZpq90+CqusmrZ97O8PLw8fkQqwoTJoMQMz9gAleW61lrDiHc hrJBL5CC35wMca576tDIoXaKU/6gIe1Bc/qP+Dr4vzMwtX6567LGaWBSlY8poDyC8ScQ guNg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b871uOS6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bt8-20020ac86908000000b003a81d7834cbsi17172659qtb.430.2023.01.03.10.19.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:19:02 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=b871uOS6; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 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; 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 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; @@ -64,6 +65,7 @@ struct TypeImpl void (*instance_finalize)(Object *obj); bool abstract; + bool object_created; const char *parent; TypeImpl *parent_type; @@ -121,6 +123,7 @@ static TypeImpl *type_new(const TypeInfo *info) ti->class_init = info->class_init; ti->class_base_init = info->class_base_init; + ti->class_late_init = info->class_late_init; ti->class_data = info->class_data; ti->instance_init = info->instance_init; @@ -367,6 +370,26 @@ static void type_initialize(TypeImpl *ti) } } +static bool type_late_initialize(TypeImpl *ti, ObjectClass *cls, Error **errp) +{ + TypeImpl *pi = type_get_parent(ti); + if (pi && !type_late_initialize(pi, cls, errp)) { + return false; + } + + for (GSList *e = ti->class->interfaces; e ; e = e->next) { + InterfaceClass *ic = 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) } } -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); @@ -510,6 +534,13 @@ static void object_initialize_with_type(Object *obj, size_t size, TypeImpl *type g_assert(type->abstract == false); g_assert(size >= type->instance_size); + if (!type->object_created) { + type->object_created = true; + if (!type_late_initialize(type, type->class, errp)) { + return false; + } + } + memset(obj, 0, type->instance_size); obj->class = type->class; object_ref(obj); @@ -518,6 +549,7 @@ static void object_initialize_with_type(Object *obj, size_t size, TypeImpl *type NULL, object_property_free); object_init_with_type(obj, type); object_post_init_with_type(obj, type); + return true; } void object_initialize(void *data, size_t size, const char *typename) @@ -540,7 +572,7 @@ void object_initialize(void *data, size_t size, const char *typename) abort(); } - object_initialize_with_type(data, size, type); + object_initialize_with_type(data, size, type, &error_fatal); } bool object_initialize_child_with_props(Object *parentobj, @@ -712,7 +744,7 @@ typedef union { } qemu_max_align_t; #endif -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 = qemu_vfree; } - object_initialize_with_type(obj, size, type); - obj->free = obj_free; + if (!object_initialize_with_type(obj, size, type, errp)) { + obj_free(obj); + return NULL; + } + obj->free = obj_free; return obj; } Object *object_new_with_class(ObjectClass *klass) { - return object_new_with_type(klass->type); + return object_new_with_type(klass->type, &error_fatal); } Object *object_new(const char *typename) { TypeImpl *ti = type_get_by_name(typename); - return object_new_with_type(ti); + return object_new_with_type(ti, &error_fatal); } @@ -792,7 +827,11 @@ Object *object_new_with_propv(const char *typename, error_setg(errp, "object type '%s' is abstract", typename); return NULL; } - obj = object_new_with_type(klass->type); + + obj = object_new_with_type(klass->type, errp); + if (!obj) { + return NULL; + } if (!object_set_propv(obj, errp, vargs)) { goto error; From patchwork Tue Jan 3 18:16:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638725 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1390718pvb; Tue, 3 Jan 2023 10:18:33 -0800 (PST) X-Google-Smtp-Source: AMrXdXtE8k1N3/iiDewCM++F/lUcQg5skX0QjYw2MDU0XTmzylHEwpliI7AwlTmt25J/BMARFZe/ X-Received: by 2002:a05:6214:3c09:b0:52d:e201:c3d2 with SMTP id nt9-20020a0562143c0900b0052de201c3d2mr69623774qvb.33.1672769912868; Tue, 03 Jan 2023 10:18:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672769912; cv=none; d=google.com; s=arc-20160816; b=Xq+X/oirCqHSxbdJiEUfWMhibZD4lVQm9zWaMMhpi87ZZxyDveS167+tkNPvzmajMJ N2xrYHUeLc77KYnyFoRlU92Dz2i/m3kIBu0H+UjMHbTiTeDSAeRHeolVoxKK/JMha9Gt +eAZQZnNmd1pNc7m3YnI68tg+iXT2kKt/8A1frTXj1L0Q7tdJ43Rychy02uo3BB48FgY gb8/4qIStMlghrhQKoH8Hgp4TlQiyjrMRRc8f83Q14FOJY5A5uP5FuMNMz/+BL94Z6+o DtsOdNyGfms0jBOOrE1vhxvY1hZ9mCQIwVcDqvrE3qXdFvnvrd+yFW8lzyPdgT3iFr2q pxkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=poMxRDPn366GZBea/9dCLSAffdWXTadkp9C7Z8GBPIw=; b=ViFDpwpsZpm4of1L8yXmC2AU3KUvkUAxb4xuxADMDsj/9ZnVvr/AZrUC4jTCutTxja LLvh+fPcUxB7e/gvq9GC8QHN7EqzxQafuvDq8ISx/gb6ppXnqHvue/PaJ1GOexRYcXSo aoAFWhbjrrKrltDxhRGqjX/iT2afidfHxOjREQhHjDNbBOzVuUb0SsCraRNLCLpGmM6E 4wHp9NZG7OCsXHVF9JwNO6xWCNdcStto/he+QgDJ21Wkyga8Y0nzi8u62c4qy7XYDArv 1gqUspzv/oA3up2zQCOTrVVMq6QK8ENFtlaua5dmnjHV1D7QBibrCrATKkreexlnQ5xj IK5g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EhHns2BU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id u15-20020ad45aaf000000b004c6a3a2e2c5si16356462qvg.539.2023.01.03.10.18.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:18:32 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=EhHns2BU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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, const char *name, void qdev_propinfo_get_size32(Object *obj, Visitor *v, const char *name, void *opaque, Error **errp); +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; #define TYPE_OBJECT "object" +typedef struct ClassProperty ClassProperty; typedef struct ObjectProperty ObjectProperty; +/** + * 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); +struct ClassProperty +{ + char *name; + char *type; + char *description; + ClassPropertyAccessor *get; + ClassPropertyAccessor *set; + void *opaque; +}; + struct ObjectProperty { char *name; @@ -135,6 +162,7 @@ struct ObjectClass ObjectUnparent *unparent; + GHashTable *class_properties; GHashTable *properties; }; @@ -1072,6 +1100,11 @@ ObjectProperty *object_property_add(Object *obj, const char *name, void object_property_del(Object *obj, const char *name); +/** + * 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(ObjectClass *klass, const char *name, ObjectPropertyRelease *release, void *opaque); +/** + * 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(ObjectPropertyIterator *iter, */ ObjectProperty *object_property_iter_next(ObjectPropertyIterator *iter); +void class_property_iter_init(ObjectPropertyIterator *iter, ObjectClass *klass); +ClassProperty *class_property_iter_next(ObjectPropertyIterator *iter); + void object_unparent(Object *obj); /** 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); +/* + * 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" 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=value" string being parsed */ - char *featurestr = features ? strtok(features, ",") : NULL; + ObjectClass *klass; + char *f; /* should be called only once, catch invalid users */ assert(!cpu_globals_initialized); cpu_globals_initialized = true; - while (featurestr) { - val = strchr(featurestr, '='); - if (val) { - GlobalProperty *prop = g_new0(typeof(*prop), 1); - *val = 0; - val++; - prop->driver = typename; - prop->property = g_strdup(featurestr); - prop->value = g_strdup(val); - qdev_prop_register_global(prop); - } else { - error_setg(errp, "Expected key=value 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 = object_class_by_name(typename); + + /* Single "key=value" string being parsed */ + for (f = strtok(features, ","); f != NULL; f = strtok(NULL, ",")) { + char *val = strchr(f, '='); + GlobalProperty *prop; + + if (!val) { + error_setg(errp, "Expected key=value format, found %s.", f); return; } - featurestr = strtok(NULL, ","); + *val++ = 0; + + if (klass) { + ClassProperty *cp = class_property_find(klass, f); + if (cp) { + Visitor *v = string_input_visitor_new(val); + bool ok = class_property_set(klass, cp, v, errp); + + visit_free(v); + if (!ok) { + return; + } + continue; + } + } + + prop = g_new0(typeof(*prop), 1); + prop->driver = typename; + prop->property = g_strdup(f); + prop->value = g_strdup(val); + qdev_prop_register_global(prop); } } 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) } } +bool device_class_late_init(ObjectClass *class, Error **errp) +{ + GPtrArray *props = global_properties; + int i, len = props ? props->len : 0; + + for (i = 0; i < len; i++) { + GlobalProperty *p = g_ptr_array_index(props, i); + ClassProperty *cp; + Visitor *v; + bool ok; + + if (object_class_dynamic_cast(class, p->driver) == NULL) { + continue; + } + + cp = class_property_find(class, p->property); + if (!cp) { + /* The property may be on the object. */ + continue; + } + p->used = true; + + v = string_input_visitor_new(p->value); + ok = class_property_set(class, cp, v, errp); + visit_free(v); + + if (!ok) { + error_prepend(errp, "can't apply global %s.%s=%s: ", + p->driver, p->property, p->value); + return false; + } + } + return true; +} + /* --- 64bit unsigned int 'size' type --- */ static void get_size(Object *obj, Visitor *v, const char *name, void *opaque, 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" static bool qdev_hot_added = false; bool qdev_hot_removed = false; @@ -901,6 +902,7 @@ static const TypeInfo device_type_info = { .instance_finalize = device_finalize, .class_base_init = device_class_base_init, .class_init = device_class_init, + .class_late_init = device_class_late_init, .abstract = true, .class_size = sizeof(DeviceClass), .interfaces = (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" #define MAX_INTERFACES 32 @@ -76,6 +78,190 @@ struct TypeImpl InterfaceImpl interfaces[MAX_INTERFACES]; }; +ClassProperty *class_property_find(ObjectClass *klass, const char *name) +{ + ObjectClass *parent_klass; + + if (klass->class_properties) { + ClassProperty *p = g_hash_table_lookup(klass->class_properties, name); + if (p) { + return p; + } + } + + parent_klass = 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 = 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 = g_new0(ClassProperty, 1); + + prop->name = g_strdup(name); + prop->type = g_strdup(type); + prop->description = g_strdup(desc); + + prop->get = get; + prop->set = set; + prop->opaque = opaque; + + if (!klass->class_properties) { + klass->class_properties = g_hash_table_new(g_str_hash, g_str_equal); + } + 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 = 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 = qobject_input_visitor_new(value); + bool ok; + + ok = 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 = qbool_from_bool(value); + bool ok; + + ok = 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 = qnum_from_uint(value); + bool ok; + + ok = 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 = 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 = NULL; + Visitor *v = 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 = class_property_get_qobject(klass, name, errp); + bool ret = false; + + if (qobj) { + QBool *qbool = qobject_to(QBool, qobj); + if (!qbool) { + error_setg(errp, QERR_INVALID_PARAMETER_TYPE, name, "boolean"); + } else { + ret = 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 = 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_properties); + iter->nextclass = object_class_get_parent(iter->nextclass); + } + return val; +} + static Type type_interface; static GHashTable *type_table_get(void) @@ -322,6 +508,7 @@ static void type_initialize(TypeImpl *ti) g_assert(parent->instance_size <= ti->instance_size); memcpy(ti->class, parent->class, parent->class_size); ti->class->interfaces = NULL; + ti->class->class_properties = NULL; for (e = parent->class->interfaces; e; e = e->next) { InterfaceClass *iface = e->data; @@ -415,12 +602,15 @@ static void object_post_init_with_type(Object *obj, TypeImpl *ti) bool object_apply_global_props(Object *obj, const GPtrArray *props, Error **errp) { + ObjectClass *klass; int i; if (!props) { return true; } + klass = object_get_class(obj); + for (i = 0; i < props->len; i++) { GlobalProperty *p = g_ptr_array_index(props, i); Error *err = NULL; @@ -428,6 +618,10 @@ bool object_apply_global_props(Object *obj, const GPtrArray *props, if (object_dynamic_cast(obj, p->driver) == 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; @@ -212,6 +213,7 @@ bool type_print_class_properties(const char *type) } array = g_ptr_array_new(); + object_class_property_iter_init(&iter, klass); while ((prop = 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->description)); } + + class_property_iter_init(&iter, klass); + while ((cprop = 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, Error **errp) bool ambiguous = false; ObjectPropertyInfoList *props = NULL; ObjectProperty *prop; + ClassProperty *cprop; ObjectPropertyIterator iter; obj = object_resolve_path(path, &ambiguous); @@ -57,6 +58,16 @@ ObjectPropertyInfoList *qmp_qom_list(const char *path, Error **errp) value->type = g_strdup(prop->type); } + class_property_iter_init(&iter, object_get_class(obj)); + while ((cprop = class_property_iter_next(&iter))) { + ObjectPropertyInfo *value = g_new0(ObjectPropertyInfo, 1); + + QAPI_LIST_PREPEND(props, value); + + value->name = g_strdup(cprop->name); + value->type = g_strdup(cprop->type); + } + return props; } @@ -124,6 +135,7 @@ ObjectPropertyInfoList *qmp_device_list_properties(const char *typename, ObjectClass *klass; Object *obj; ObjectProperty *prop; + ClassProperty *cprop; ObjectPropertyIterator iter; ObjectPropertyInfoList *prop_list = NULL; @@ -172,6 +184,18 @@ ObjectPropertyInfoList *qmp_device_list_properties(const char *typename, QAPI_LIST_PREPEND(prop_list, info); } + class_property_iter_init(&iter, klass); + while ((cprop = class_property_iter_next(&iter))) { + ObjectPropertyInfo *info; + + info = g_new0(ObjectPropertyInfo, 1); + info->name = g_strdup(cprop->name); + info->type = g_strdup(cprop->type); + info->description = g_strdup(cprop->description); + + QAPI_LIST_PREPEND(prop_list, info); + } + object_unref(obj); return prop_list; @@ -183,6 +207,7 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename, ObjectClass *klass; Object *obj = NULL; ObjectProperty *prop; + ClassProperty *cprop; ObjectPropertyIterator iter; ObjectPropertyInfoList *prop_list = NULL; @@ -216,6 +241,18 @@ ObjectPropertyInfoList *qmp_qom_list_properties(const char *typename, QAPI_LIST_PREPEND(prop_list, info); } + class_property_iter_init(&iter, klass); + while ((cprop = class_property_iter_next(&iter))) { + ObjectPropertyInfo *info; + + info = g_malloc0(sizeof(*info)); + info->name = g_strdup(cprop->name); + info->type = g_strdup(cprop->type); + info->description = g_strdup(cprop->description); + + QAPI_LIST_PREPEND(prop_list, info); + } + object_unref(obj); return prop_list; From patchwork Tue Jan 3 18:16:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638728 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1390855pvb; Tue, 3 Jan 2023 10:18:52 -0800 (PST) X-Google-Smtp-Source: AMrXdXvRrJD5pYyLerWqZuNmlDGKlqQSqKaoR1IkDc6uF22rCKzv5ccvXx8bSodMWW2e+1Jo0rZX X-Received: by 2002:a05:622a:124b:b0:3ab:7bb3:4707 with SMTP id z11-20020a05622a124b00b003ab7bb34707mr45710734qtx.64.1672769931843; Tue, 03 Jan 2023 10:18:51 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672769931; cv=none; d=google.com; s=arc-20160816; b=SVMawyA8XMzki+DsmooSAzoCtdJmYZ7Np7js37VlY4Iv4Cx9EoxJAynsRHaTpJOoas coA+PZpA00O4dc9MZ/Na2bNz8I5GZ/oKkWaYBpTGiuiXyURLNpHXQItz6UD/h5xDiqeY qr9eC52wa5ML0DP8rPrOjadvoJCS1+pcSTZi8ZyNWR4nQfFUPMkKVZ+j/N0ENeebLOUF ClTirzwnRT2gwzwbz1dm3ZSVzWX1ziFm4ejKlsbGf5dJtLTw7JemqVkLTQ5xHulqsWrU WDs7cXUumcHjnPGZVDYG2QU4YP69Srgnvz+Y5CzKkRXmh8bCwm0K7QIuHFccF2Pg+svR eFDw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=HqfB1rYBt/JJ41xGurvUZv7qvN+1zDd4tBuTAwoD6lU=; b=a5t393YIyXE/Z9H59gLF0iZhedjdkNZ9DO+0NXjgFp8jbh0SuSpciIuepRXwKCJyGL vwwIMwGG4a+M5RMRHLGk7Xcb5shUHSVeo3AA/HqFmXTJH2eQhTpxfSYlpOT4r+AgJhK7 wz5GwhsQITOoltTk/uehEvRzun9sHsDsUuNFXZrM0u9QwNuwzMh40DdTzsJr4kSIolzG ZpPoS4A+MC8vr/sLilXU7H4xx+InjjqHpuhw8/XzB5fR/1iF75f92xhwHzcMSUjvFltP 36zGxYbrWEafzJ/B+EcjJMhsjmFHlxk+cTmMI88ZrJiLOPGV/xyH0VFo9xrxjdJTy120 8k/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zs4hdB3a; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z13-20020a05622a124d00b003a80ecd960csi16429562qtx.450.2023.01.03.10.18.51 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:18:51 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=zs4hdB3a; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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, bool value, Error **errp) } } -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 = { .name = TYPE_AARCH64_CPU, .parent = TYPE_ARM_CPU, .instance_size = sizeof(ARMCPU), - .instance_finalize = aarch64_cpu_finalizefn, .abstract = true, .class_size = sizeof(AArch64CPUClass), .class_init = aarch64_cpu_class_init, From patchwork Tue Jan 3 18:16:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638726 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1390780pvb; Tue, 3 Jan 2023 10:18:42 -0800 (PST) X-Google-Smtp-Source: AMrXdXsvyOSFWbwpSGYUIYxTIwTAPSOIeu7mV+dUtA3Ewcb8I0MuMAxxxeCCV8FF4ufqYoKeh/iI X-Received: by 2002:a1f:2942:0:b0:3be:2175:a7f2 with SMTP id p63-20020a1f2942000000b003be2175a7f2mr18155098vkp.11.1672769921708; Tue, 03 Jan 2023 10:18:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672769921; cv=none; d=google.com; s=arc-20160816; b=o+ophvKkUB+xtz/nE3I8fqT/P026o17xIUVC3wrBWpXIUZXHmP1fRWSNnTS5qZkbyH Usi96Ask0v8hpm7wRXkNKkrbR+eeGWm1pv+sWDZfDh/OTy0GTrEeWGOI1vVElEk2pLZu e0jPN2dlScl+VEUPTlGKgh2F4tHaRnIDz/gnbMQhSiQzAutC6ykT2x131IkgnRa1g5SC mZ2uluugnaDZhzP9OsP1g4/cDv1+ztD3KxOUNo1EgLtYPieLyAL3FFec7AMdZ3+7KS2n 0IGnouyT4VzL0MD2dKq0ZixnHUrqNQ/xHDp4mgTciM5aeXd6AkpakuyI/vPNN8nja2bH cPsQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=xWi29oKGa+vNl3/kuxAMom41NeEPlRY6brtaMJqGau4=; b=ROj0Tmqdv2ncudkJNXzgBduVXXYYQ7MQM4ZbRVqbc5u/xmCUnugIptqqAQS/WpDGcX ANO6alIyhRsO5pGSwnN3tl0iX43Qtk/GZBJUnktjUz2LVEYoNP6PuIFs7vuX6ilIWZSh yT8Fz5s9y5AUQdiarTH8/coycbQ+irNg5Y8OjWPk0voJ3KXBqZElPErCdxkQvMSQfl3e Jt47P3b8L8NdqWrODmgms6ZMR7I+FojK2PA+WoaA3qrgGODxk9l6YHJn1BxKw8uc3nbY 7QkFsCFJHKBjMoxJxu+4OfOCSOx3Ptr4ZI+SOBcOUYeQSjCCs7Y7Okf/LU6cDjZiN63e kKig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=szhoI5zw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id o2-20020a375a02000000b006fbb1285176si15617517qkb.347.2023.01.03.10.18.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:18:41 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=szhoI5zw; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Create an arm cpu class with a specific abstract parent class. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- 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; -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); +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 = data; } -void arm_cpu_register(const ARMCPUInfo *info) +void arm_cpu_register_parent(const ARMCPUInfo *info, const char *parent) { TypeInfo type_info = { - .parent = TYPE_ARM_CPU, + .parent = parent, .instance_size = sizeof(ARMCPU), .instance_align = __alignof__(ARMCPU), .instance_init = arm_cpu_instance_init, From patchwork Tue Jan 3 18:16:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638731 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1390936pvb; Tue, 3 Jan 2023 10:19:07 -0800 (PST) X-Google-Smtp-Source: AMrXdXvbdaKwF8mcGUIN+6WJOA6np54JcLfKnlj639HSDLZUibVa6TevfCK79nQ6ArPX4sWtHqLy X-Received: by 2002:ac8:74d1:0:b0:3a8:e35:257e with SMTP id j17-20020ac874d1000000b003a80e35257emr58814930qtr.20.1672769947665; Tue, 03 Jan 2023 10:19:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672769947; cv=none; d=google.com; s=arc-20160816; b=EOCZWlURUOAWVTJubwldYoo/qpnltbSUjqdUofEFbEgJT8c/Nhg4IIU/eYNUouiOFD insrafxUJ6goJPXs82tYIXUfywFBfZP0mDAC7cfi52pzys2DccVFXhLsFAHZFEfzrgXu lJRWnFan/qOA3yrd+FlhUpagCIffm1FhIC6XwspxwhBW1Mrzp++ySd0Z8RzA81Eku9xk 0K0J3rY61Fk8dDL5vvvgC6TQtiOGEA17tTy3AIOfTszf8E/Y5DjQS4VqmP91l/3L0mdG ootx6jesg7XhC+2fH4iOTETjCY+TmcnSR4cyy1xcKbAF1eVQL3M/HM+OkHUWfefaKNt0 gcnw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/hcmB2LT/3scWI6D2yw07Zg5GL1YtQ6uMDjg/q/TVb4=; b=K31DwblyHvaAxWdtHDZQfYTPhJmVzY6a9M5NBcijh5N7IPuodfqI1CS121HZkhddNq JGVTDnS1Aee8roBjYp3JijJUhyf7G8uYBwM5ZNf9m5tcqZAdLdkUudjNQe3OikATa4N+ Qdpc7hMzN/tR+6L2Ny+jdrQVdoAP756qr2hZLAPjqbEly8SMNlw9LwpKRmwgDh8vdDyI jJZW1mKu0Aq1sVYDFiUoLyrLerwf+wDtv6uyPLTE5TUqZVejvYxX5YctEuj5z6d0VOGR 0h751FbvJKGjYeGQi1gxkI5JM/54fJ3yv4rNC0qVh1ciLKNZvavSTcrDdW+2AHia4X+S s4Ng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XUGpTbJP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f8-20020a05620a280800b0070548ec99casi5288408qkp.388.2023.01.03.10.19.07 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:19:07 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=XUGpTbJP; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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; #define TYPE_ARM_CPU "arm-cpu" +#define TYPE_AARCH64_CPU "aarch64-cpu" OBJECT_DECLARE_CPU_TYPE(ARMCPU, ARMCPUClass, ARM_CPU) @@ -38,13 +39,17 @@ typedef struct ARMCPUInfo { } ARMCPUInfo; void arm_cpu_register_parent(const ARMCPUInfo *info, const char *parent); -void aarch64_cpu_register(const ARMCPUInfo *info); static inline void arm_cpu_register(const ARMCPUInfo *info) { arm_cpu_register_parent(info, TYPE_ARM_CPU); } +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; }; - -#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); 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 { unsigned int gt_cntfrq_period_ns(ARMCPU *cpu); -void arm_cpu_post_init(Object *obj); - uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz); #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; } -void arm_cpu_post_init(Object *obj) +static void arm_cpu_post_init(Object *obj) { ARMCPU *cpu = ARM_CPU(obj); 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 "); } -static void aarch64_cpu_instance_init(Object *obj) -{ - ARMCPUClass *acc = 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 = ARM_CPU_CLASS(oc); - - acc->info = data; -} - -void aarch64_cpu_register(const ARMCPUInfo *info) -{ - TypeInfo type_info = { - .parent = TYPE_AARCH64_CPU, - .instance_size = sizeof(ARMCPU), - .instance_init = aarch64_cpu_instance_init, - .class_size = sizeof(ARMCPUClass), - .class_init = info->class_init ?: cpu_register_class_init, - .class_data = (void *)info, - }; - - type_info.name = 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 = { .name = TYPE_AARCH64_CPU, .parent = TYPE_ARM_CPU, .instance_size = sizeof(ARMCPU), .abstract = true, - .class_size = sizeof(AArch64CPUClass), + .class_size = sizeof(ARMCPUClass), .class_init = aarch64_cpu_class_init, }; From patchwork Tue Jan 3 18:16:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638742 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1392121pvb; Tue, 3 Jan 2023 10:22:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXtsogyfeRMvKFA9tH2dz4xNz9eJ3ApRzMiEuK0P1bNVrxfNuAlXusMJ4t4aPgKjeC68L/xL X-Received: by 2002:ac8:445a:0:b0:3a8:e35:258f with SMTP id m26-20020ac8445a000000b003a80e35258fmr64311376qtn.31.1672770135068; Tue, 03 Jan 2023 10:22:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770135; cv=none; d=google.com; s=arc-20160816; b=TMnpt6K8jEbHluJkXoY9eBwG5wbb1dVRoBqvDK5SJjQ6SoXY9NXkeaZsUpM4SUcxoJ jqmBfKzi9EY1G6q8yttXJTn4qEWK91EJnbZN/rLiUNq67gI7PNBVXnOKiio2xox3lDzo DcEI8PsbUG5h2++KXD+NVumgNDgz5GYsVh3yT+s1ssQC+01nSN0xm1ROKiUR/7HFQWZs zxJdfrb05G0K169G665lstxe6jUonB/XzNXOJTQ68LuMsLjrDCs2St8xhXIYXgkCTayY jDUKnygdbE41XkNj+8zPf9ROlswbNnlpcZXKYMoTra/5g+Yh9VCeuFXDS5qhgyQp6nX+ a9mg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ox6lsVTv8H7bR8+2oGArM6AIjDyJ3hXTv/IB/m/B3mo=; b=RsWZhbgpmMfOfbGgDBE+prudVe7XQMxmQTc6ILwhnjgK1qlanrLGRNe9iCS56UcOcK YaqjOENSPRwBhC7ZTXz6BrcFdPVUKnH9HvNapx1civ/oC8JoWuzyJ7JI9xmBQoDIDPdf +35s7YFVgHItHY7NktBrci4heycQDsiTrM4YYZdT79etnvwO9e3CzSGG+F0t1LUr1N6c rhvaYb2y2EwrknXUS8ELJ59lLEoHasTdG+8FlFGsNGteP4jeQScyPAWkTvL1rmOH+Jwq O/avG9z1T9XsVL2+I6hNva44PauVG14u8iLMxN4AQ16KxcRlVDu3EtEixPGPJGmMCVQe Nsmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O4U5yWLi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id fz7-20020a05622a5a8700b003a6905f8495si17023865qtb.32.2023.01.03.10.22.14 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:22:15 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=O4U5yWLi; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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; #define TYPE_ARM_CPU "arm-cpu" +#define TYPE_ARM_V7M_CPU "arm-v7m-cpu" #define TYPE_AARCH64_CPU "aarch64-cpu" OBJECT_DECLARE_CPU_TYPE(ARMCPU, ARMCPUClass, ARM_CPU) @@ -45,6 +46,11 @@ static inline void arm_cpu_register(const ARMCPUInfo *info) arm_cpu_register_parent(info, TYPE_ARM_CPU); } +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 = { static void arm_v7m_class_init(ObjectClass *oc, void *data) { - ARMCPUClass *acc = ARM_CPU_CLASS(oc); CPUClass *cc = CPU_CLASS(oc); - acc->info = data; #ifdef CONFIG_TCG cc->tcg_ops = &arm_v7m_tcg_ops; #endif /* CONFIG_TCG */ @@ -1149,18 +1147,6 @@ static const ARMCPUInfo arm_tcg_cpus[] = { { .name = "cortex-a8", .initfn = cortex_a8_initfn }, { .name = "cortex-a9", .initfn = cortex_a9_initfn }, { .name = "cortex-a15", .initfn = cortex_a15_initfn }, - { .name = "cortex-m0", .initfn = cortex_m0_initfn, - .class_init = arm_v7m_class_init }, - { .name = "cortex-m3", .initfn = cortex_m3_initfn, - .class_init = arm_v7m_class_init }, - { .name = "cortex-m4", .initfn = cortex_m4_initfn, - .class_init = arm_v7m_class_init }, - { .name = "cortex-m7", .initfn = cortex_m7_initfn, - .class_init = arm_v7m_class_init }, - { .name = "cortex-m33", .initfn = cortex_m33_initfn, - .class_init = arm_v7m_class_init }, - { .name = "cortex-m55", .initfn = cortex_m55_initfn, - .class_init = arm_v7m_class_init }, { .name = "cortex-r5", .initfn = cortex_r5_initfn }, { .name = "cortex-r5f", .initfn = cortex_r5f_initfn }, { .name = "ti925t", .initfn = ti925t_initfn }, @@ -1187,6 +1173,24 @@ static const ARMCPUInfo arm_tcg_cpus[] = { #endif }; +static const ARMCPUInfo arm_v7m_tcg_cpus[] = { + { .name = "cortex-m0", .initfn = cortex_m0_initfn }, + { .name = "cortex-m3", .initfn = cortex_m3_initfn }, + { .name = "cortex-m4", .initfn = cortex_m4_initfn }, + { .name = "cortex-m7", .initfn = cortex_m7_initfn }, + { .name = "cortex-m33", .initfn = cortex_m33_initfn }, + { .name = "cortex-m55", .initfn = cortex_m55_initfn }, +}; + +static const TypeInfo arm_v7m_cpu_type_info = { + .name = TYPE_ARM_V7M_CPU, + .parent = TYPE_ARM_CPU, + .instance_size = sizeof(ARMCPU), + .abstract = true, + .class_size = sizeof(ARMCPUClass), + .class_init = arm_v7m_class_init, +}; + static const TypeInfo idau_interface_type_info = { .name = TYPE_IDAU_INTERFACE, .parent = TYPE_INTERFACE, @@ -1197,10 +1201,14 @@ static void arm_tcg_cpu_register_types(void) { size_t i; + type_register_static(&arm_v7m_cpu_type_info); type_register_static(&idau_interface_type_info); for (i = 0; i < ARRAY_SIZE(arm_tcg_cpus); ++i) { arm_cpu_register(&arm_tcg_cpus[i]); } + for (i = 0; i < ARRAY_SIZE(arm_v7m_tcg_cpus); ++i) { + arm_v7m_cpu_register(&arm_v7m_tcg_cpus[i]); + } } type_init(arm_tcg_cpu_register_types) From patchwork Tue Jan 3 18:16:14 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638724 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1390647pvb; Tue, 3 Jan 2023 10:18:22 -0800 (PST) X-Google-Smtp-Source: AMrXdXu3oj0qSna26by3PsxbFMleCbPOl7DeVycLlmHVOz3B8ndgn70MfAogYrujjUEcvdN9M2Id X-Received: by 2002:a05:622a:2605:b0:3ab:a1cf:b2ca with SMTP id ci5-20020a05622a260500b003aba1cfb2camr31013926qtb.27.1672769901940; Tue, 03 Jan 2023 10:18:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672769901; cv=none; d=google.com; s=arc-20160816; b=bcUCp8Vjoi60E6Zk9N9hFtCtWmzA2tFoC7lmaVnZzdWoA8C7G8z6FDlxiXpiMhLY7e RaXTqonxoYQ6SqJ+JMIf0L63SFkOuEOl5YUNd3R9FlNMdWeQgS9r0fZX26mDsn+/cmbx fuZsvvTdO34eFl6UvmqJzHIdkAafK3CWTyRORzxIYmVRjih2CgRKkuzlGfcfYd9H8gTI a/0uWL4XNORVsrewj31X3eCA1QDotwTWbRjmYe8O7jOMLS/dijLcHgQ6qtNsXRmGGKwq bhiRT9ZO7CS1CRdAbwIeX+GbJ1TtR4BJleZLqHcPRHG8+UXGVk0PcXnHQ+t7eb/dZwq7 BkUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XAGObJvGqrVWdz2gSKRqPWH5ISliRfssMEo9w+SvRe8=; b=A0+Maj+ko4l0wg+TL0xHjxdWNbajXEkSd9gViVzW6JeE0cKdx1D6wRKgStE6scT4wo PM75oLz1ShASvYrPSnchl0vRGoDwCH1d6tI/vvN0kQxa+r6ZIvW72hXcSofsX0t/9BzV X7Rptojgp5vetM73Y7cP2/McDiLbOw1q2nBiRUrCkjMtaDELcwVj9mwVO81U34P0+HA/ QZ/222AeyxFOwQSHOOTnCrlvRj+tu/pd/vxidwK/r9yixi05t5zVO72+4LYMUrmboApk jYoVDmI7Aft7KLibHkeNGj4tby3W25x95adQg3FjPeY8jYmULVUnvdHZthBzvO8hhZ1D KGmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LSS15VX8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id fw4-20020a05622a4a8400b0039ce973b0ebsi17178194qtb.486.2023.01.03.10.18.21 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:18:21 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LSS15VX8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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; 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); } -static void cpu_register_class_init(ObjectClass *oc, void *data) +static void arm_cpu_leaf_class_init(ObjectClass *oc, void *data) { ARMCPUClass *acc = ARM_CPU_CLASS(oc); + const ARMCPUInfo *info = data; - acc->info = data; + acc->info = info; + if (info->class_init) { + info->class_init(acc); + } } 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 = __alignof__(ARMCPU), .instance_init = arm_cpu_instance_init, .class_size = sizeof(ARMCPUClass), - .class_init = info->class_init ?: cpu_register_class_init, + .class_init = arm_cpu_leaf_class_init, .class_data = (void *)info, }; From patchwork Tue Jan 3 18:16:15 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638763 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1394704pvb; Tue, 3 Jan 2023 10:28:56 -0800 (PST) X-Google-Smtp-Source: AMrXdXskRYFSZ+SiRk8w+v6sM1WDU1CbHxCFlEk8b3fsh96HUDAKwshjVRUehDQATtsNR7BwQ5GU X-Received: by 2002:a05:622a:4d48:b0:3a6:258d:4387 with SMTP id fe8-20020a05622a4d4800b003a6258d4387mr74605726qtb.13.1672770536340; Tue, 03 Jan 2023 10:28:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770536; cv=none; d=google.com; s=arc-20160816; b=SpcXkDkiUddVbTRHPZXuHLWGvRii/FwzlHYmqLvIPSaRHNLFxX1HkFGjCaYeHj8rgV Amrp1Qbu/QB7AHUhzOl7B+8vScZUP6GLwrNZe/+r4fhlerzNmoiPN9AwN0QuNyC6RH1P SLxUhzUC9jqZSpYUunHvLsMwTvLcYbqR2Pg5xJ2DSkF9nqI0xYORMyAup7KTcS+zhG+i Mlj36I72Q/uMBwepl2qIrcnq9eQrY/UDz22piAPfzIjPht5mqsUsulD/Zv3tgqWDrZI9 HKB8JXJ6tuz9FgLGWxG+/y4qnQ2DyVyPNpTptsrKz8ngk+drb8JXX8kDfBQbTcgRJaY/ Vd8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Q1oCoDY8fhpidPn09tNWnDVDs+nP6yjSMDN5nvvhyRs=; b=dRJpnsX98rMHVhdB8YzVwnyQZe0yqUT3l/7NopTMobJDPtSm9YmsZxZ7E3l7TH+TSz 1MPPcwqbybtz7OHR2GfkP+OPyaNYP+gNYIhIo/ZIqS8cbPFSXT2mmUqqJCrYsk27O4wC ytwKBrE6rSznvdjJHOBIo3kRVnrwOlEHxQUs48jxbgZ0auJC0A3o0+o9JylRiYzP6Yjj U9oveWWrYJNVx04LjyE/Lc83Sa7QiOQsGyvNHbZ3pfsiRJTtAIqdOfHtDIqLvo9Xo9m1 o18oNl6ldASWARNjHeVvcYSx63KgRdZoMqJ4LYCLMogtvSHy+JpfIvqgNOjd4tKYclJX hXnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SkvaT8l+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s12-20020a05620a254c00b00704d8dcff6asi8627644qko.437.2023.01.03.10.28.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:28:56 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SkvaT8l+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 */ } -static void arm_cpu_instance_init(Object *obj) -{ - ARMCPUClass *acc = 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 = ARM_CPU_CLASS(oc); @@ -2270,7 +2262,7 @@ void arm_cpu_register_parent(const ARMCPUInfo *info, const char *parent) .parent = parent, .instance_size = sizeof(ARMCPU), .instance_align = __alignof__(ARMCPU), - .instance_init = arm_cpu_instance_init, + .instance_init = info->initfn, .class_size = sizeof(ARMCPUClass), .class_init = arm_cpu_leaf_class_init, .class_data = (void *)info, @@ -2287,6 +2279,7 @@ static const TypeInfo arm_cpu_type_info = { .instance_size = sizeof(ARMCPU), .instance_align = __alignof__(ARMCPU), .instance_init = arm_cpu_initfn, + .instance_post_init = arm_cpu_post_init, .instance_finalize = arm_cpu_finalizefn, .abstract = true, .class_size = sizeof(ARMCPUClass), From patchwork Tue Jan 3 18:16:16 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638750 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1393156pvb; Tue, 3 Jan 2023 10:24:58 -0800 (PST) X-Google-Smtp-Source: AMrXdXvDaXeF+pRVCIl9W8PeF2wriR5/wfeCjGHCFYDySUsH1e+NDUYNwO6o0gdIH32Svhx0RiHd X-Received: by 2002:a05:622a:1e91:b0:3a9:72ea:5a5d with SMTP id bz17-20020a05622a1e9100b003a972ea5a5dmr70441745qtb.57.1672770298757; Tue, 03 Jan 2023 10:24:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770298; cv=none; d=google.com; s=arc-20160816; b=zlxjX4/8aazeeEoWiKcfm0AT2dhurqXzeY1k4yicRA4RH1PH9yACQYH2fumUwefhLm 7jXTf1rWG8UFCdPEJC7NOBQ9/kHfKvPJUoT2PtxdoCNirGzO/hDj+tP/Est0uJCg1c/U RY6DPx6mkql76eJEJ7UBBe9qCBM9Fe+WgftMre6cda2u6LSW0qCoCkTJNtrav54xJw5M QLJd8Ow+4fhI7P3ge68IpZiVTGi7pgJ1R/gPUBVeFT3hdRASaAUQN4lNUcX/W+V6VMMA 3zahJknr9U83kWg6env2oAA4/IOIgwaEBcunh94gAI9HbZFh9/i0A8/5emXdlEC8hv7Y xWZQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ZkEGcogj27YdFJQTywgiITgHI/jXlYMGF8YkSZKNLjc=; b=XLI2pjU+MK4Cdt574XixCs5br3e48xfTFA+VDNGAFRghcplTxx8oa1XKxds0itX5D4 Wc6F5QTyp1gTf75qy0Klwn9Ly5TSxsaQ2jGfeqmzebsCfeP8I7MuKi1YmgRwkVLIFAej 8JiKVkbhDvKmV8jxf2+jMwxnwgourkG7A18qbVkk/9TldxTLdTRo4Y7VLv1Ya2a+RDh7 bFUKRI1zLdnks6QLCjORbcn5u2plSLkZ+QMx9JWuvosSTU4I1mW9d9udseVwWM4J3DQ3 cZg0fzNVQhi/VyQ0PluiXxtnz7XoT6hf5uO0NS4imQXP1jumXfhzMHTtNGjnkbahG25K rf7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OdlkCUnO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q24-20020a05620a2a5800b0070209239ba6si16876823qkp.400.2023.01.03.10.24.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:24:58 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=OdlkCUnO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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; }; 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 clustersz) static void arm_cpu_initfn(Object *obj) { ARMCPU *cpu = ARM_CPU(obj); + ARMCPUClass *acc = ARM_CPU_GET_CLASS(cpu); cpu_set_cpustate_pointers(cpu); cpu->cp_regs = g_hash_table_new_full(g_direct_hash, g_direct_equal, @@ -1189,6 +1190,8 @@ static void arm_cpu_initfn(Object *obj) QLIST_INIT(&cpu->pre_el_change_hooks); QLIST_INIT(&cpu->el_change_hooks); + cpu->dtb_compatible = 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 - /* DTB consumers generally don't in fact care what the 'compatible' - * string is, so always provide some string and trust that a hypothetical - * picky DTB consumer will also provide a helpful error message. - */ - cpu->dtb_compatible = "qemu,unknown"; cpu->psci_version = QEMU_PSCI_VERSION_0_1; /* By default assume PSCI v0.1 */ cpu->kvm_target = QEMU_KVM_ARM_TARGET_NONE; @@ -2243,6 +2241,13 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) #ifdef CONFIG_TCG cc->tcg_ops = &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 hypothetical + * picky DTB consumer will also provide a helpful error message. + */ + acc->dtb_compatible = "qemu,unknown"; } static void arm_cpu_leaf_class_init(ObjectClass *oc, void *data) From patchwork Tue Jan 3 18:16:17 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638733 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1391121pvb; Tue, 3 Jan 2023 10:19:33 -0800 (PST) X-Google-Smtp-Source: AMrXdXvCOrqihOIb4GUWkR18gB2pXX/b5ldJmOrJJ0hyrbtofAM4Af+ITLveu2IVKvqtTAjAvFqP X-Received: by 2002:a05:6214:154a:b0:4c6:5753:cf88 with SMTP id t10-20020a056214154a00b004c65753cf88mr63171525qvw.7.1672769973222; Tue, 03 Jan 2023 10:19:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672769973; cv=none; d=google.com; s=arc-20160816; b=QjmV4BM6fs7D007h39sz7i9oQ7PWKHiOAw2M22WE4j6CbKMRIkGPmYn8q80APwTgya lK7vnjh3KgnxNKgolgazTjEbvbN8oq9OpnplNDk0UNKmKqLHmvM8PhNSBZQL9BFdpZ9L lBbbVju6Q2b2Uhhq8NC7h/pXPjyIa33O78mii9ZyxH4Lk/KlyBTXD6fnIkCUinbjIzS9 PP3XF2pFY0EeRMjPDgE77nG4+epjE1UObdNl0+El9qbHuxtGnOR+FrUrzXLmbv1je2eL 2YLtl7uhtz4xRpLQk5AdzvT24jyV7ThzLFDzB054Bsvk9xOoS/FYIGrsZgkHJGMyD3CS e04Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/p9QPpDGvjmZI1N9rUlYvW7qA56IptLsG0qWqJxJf9I=; b=Yn3lHqaxe7vX5OvZkSb3LF91sP5wVAtggn8t/bY7Z99k6FrTKDmvcEIxsxgTeBFLkt J/Dq5Ne3hVr2pm2gJCQ7VrsOB758NhXKe2UR8OznhOkeXk+rw2pf7t1mA4DgxbdzFZui PdZ1Wy9tsFF/OLN2/Fw5aDZpUNtTsjTaeRhxT40xxzKnGtlNl95mcwq62+Utq01SzC0W 5EWSPQP34AMDyUbNpA+2vDJ1+PjvLxtamCou64dWQi8pGWGEdhZ6Ier8q0MZYAhW1YB8 Brh3+VITI9EZyNg35jqlygRCru5nF4UqWaukCz4+52k7mFN9S6yrdf7D8dEkEf7nOh1/ l7Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FRR2GH0A; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id z21-20020a056214041500b004c6e54939c9si16573000qvx.410.2023.01.03.10.19.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:19:33 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=FRR2GH0A; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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 { /* 'compatible' string for this CPU for Linux device trees */ const char *dtb_compatible; + + /* Internal CPU feature flags. */ + uint64_t features; }; +static inline int arm_class_feature(ARMCPUClass *acc, int feature) +{ + return (acc->features & (1ULL << feature)) != 0; +} + +static inline void set_class_feature(ARMCPUClass *acc, int feature) +{ + acc->features |= 1ULL << feature; +} + +static inline void unset_class_feature(ARMCPUClass *acc, int feature) +{ + acc->features &= ~(1ULL << feature); +} + void register_cp_regs_for_features(ARMCPU *cpu); void init_cpreg_list(ARMCPU *cpu); 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); cpu->dtb_compatible = acc->dtb_compatible; + cpu->env.features = acc->features; #ifdef CONFIG_USER_ONLY # ifdef TARGET_AARCH64 From patchwork Tue Jan 3 18:16:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638751 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1393541pvb; Tue, 3 Jan 2023 10:25:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXtOvUOkwdT11JZEyiVqbGXBn/kEW/p3c26NkuI0QGcscmzdT5SlE6tRC21Kep6PleOFnRCm X-Received: by 2002:a05:6214:319c:b0:4c6:e395:b702 with SMTP id lb28-20020a056214319c00b004c6e395b702mr68861269qvb.34.1672770358838; Tue, 03 Jan 2023 10:25:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770358; cv=none; d=google.com; s=arc-20160816; b=as2wj39MBHfICWobDu/hr9kI9Up2dLLdvPBcnEnB7qe++Ej6AiDH3p1sw3iziN152v xVrym6StgNTX3HHblwuBTmGmRdpLQO69W0dt4QM+lalNdQLA1Dq9WWzdqI2A+tPIyAcz Cu5MSEbFVDebnTjZJah5ea1qZ3QIYtIqiihYUsRkNOZ2aUl+n0S1OdsJ6YAS1Lz4M6qk Bx/p+a//ZEyP2fAFUdOzrJOwgTmvwSbg4RnEEDfDoTZiq98iDvWWENjshHesl7IBLyz8 I1bFsOsUTJSIrXn2vyZzTb6QsrU8PQeZMsKDOuFXM+F+VAIYxLGigFR5ZV03lbTmJny4 iN2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=TF6WRrkDyTJgx1M6YcuNUMdyG++qDPJUqtoWjJFxRL0=; b=o1slt3Xuqxhli8wlQueKEas5Z0SZR3Du+piVcvtmG6w/BuyEhxYvyh/Xk4XCb94wla QrOV+7jKkdfUSPFrQbnXZjYefB38gDjboHK0C3q0UUFm8GV0/ZTVeENKoXn1pt2/b5HJ o47fQxMAtq/Mx/+iTZ1sqtMdT9739z4dPUxrj4CPWRTNuuN0TdVsbMWS5Angx8ecn0pZ ECOSRaTnIHjEl6nQFTHp9io0iuZK9dZW7Vhbtl7POcOCQNHfBv4bM2Y1M4gx8z810tsl UZp3x9+kQ315WhPyuzsTlUSwnc/y7vqggvX2twP9AkQHWXmlzZRy4k3aKfB/HH40vRyD G9Og== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y0JuM+N+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id w24-20020a05620a0e9800b006ff1cf821eesi15958261qkm.194.2023.01.03.10.25.58 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:25:58 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=y0JuM+N+; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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); } +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 { /* 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 type. + */ + uint32_t kvm_target; }; 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 = 2 } ARMPSCIState; -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 ARMISARegisters *id) */ #define cpu_isar_feature(name, cpu) \ ({ ARMCPU *cpu_ = (cpu); isar_feature_##name(&cpu_->isar); }) +#define class_isar_feature(name, acc) \ + ({ ARMCPUClass *acc_ = (acc); isar_feature_##name(&acc_->isar); }) #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) cpu->dtb_compatible = acc->dtb_compatible; cpu->env.features = acc->features; + cpu->isar = acc->isar; + + cpu->midr = acc->midr; + cpu->ctr = acc->ctr; + cpu->pmceid0 = acc->pmceid0; + cpu->pmceid1 = acc->pmceid1; + cpu->id_aa64afr0 = acc->id_aa64afr0; + cpu->id_aa64afr1 = acc->id_aa64afr1; + cpu->clidr = acc->clidr; + + QEMU_BUILD_BUG_ON(sizeof(cpu->ccsidr) != sizeof(acc->ccsidr)); + memcpy(cpu->ccsidr, acc->ccsidr, sizeof(acc->ccsidr)); + + cpu->revidr = acc->revidr; + cpu->id_afr0 = acc->id_afr0; + cpu->reset_fpsid = acc->reset_fpsid; + cpu->reset_sctlr = acc->reset_sctlr; + cpu->reset_auxcr = acc->reset_auxcr; + cpu->pmsav7_dregion = acc->pmsav7_dregion; + cpu->sau_sregion = acc->sau_sregion; + cpu->dcz_blocksize = acc->dcz_blocksize; + cpu->gic_num_lrs = acc->gic_num_lrs; + cpu->gic_vpribits = acc->gic_vpribits; + cpu->gic_vprebits = acc->gic_vprebits; + cpu->gic_pribits = acc->gic_pribits; + cpu->kvm_target = acc->kvm_target; #ifdef CONFIG_USER_ONLY # ifdef TARGET_AARCH64 @@ -1225,7 +1251,6 @@ static void arm_cpu_initfn(Object *obj) #endif cpu->psci_version = QEMU_PSCI_VERSION_0_1; /* By default assume PSCI v0.1 */ - cpu->kvm_target = QEMU_KVM_ARM_TARGET_NONE; 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 = "qemu,unknown"; + acc->kvm_target = QEMU_KVM_ARM_TARGET_NONE; } static void arm_cpu_leaf_class_init(ObjectClass *oc, void *data) From patchwork Tue Jan 3 18:16:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638756 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1394274pvb; Tue, 3 Jan 2023 10:27:49 -0800 (PST) X-Google-Smtp-Source: AMrXdXtp+ubYpkZD5PQm5QRphS02UmmOsQOoA3H2zcxvnERtDs9bqJ8nH4lr2dt1du/EckGbT51U X-Received: by 2002:a0c:eecc:0:b0:531:c5ae:b9a1 with SMTP id h12-20020a0ceecc000000b00531c5aeb9a1mr12607370qvs.25.1672770469343; Tue, 03 Jan 2023 10:27:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770469; cv=none; d=google.com; s=arc-20160816; b=dUaQdYoS0rs/HWYM/4IpT0lsyedau1swmJ4ikk+GRUYPyJTc0pJJKfxK2T630UiqVn fCChDftzibtNueR5ysLw54KSRJy/Q7sVujs6P54viIf2hRdcEqrHxRMkf48Zg7C69kIA UDK173HXN5jpbw20Ngh6hHb22mzKPj7yxN60HCC7rB9L6rE6jDGigpk/slvNtKZbOi2z 9287Y97D+8zJ/MvGJOlDAmxVPZLzrqUC/dX3pWwLBVIoO8Js2fy1C+wcpG4bjR7PMdDv Q7b9Yhw17kjHx24Z4izslqU1D225dSr9+IWrQmTZRPXf620ZQ+pYRBhLrC4UGwriOQTa CWbg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=rb9AmI85idWoLsBzV+dL4jn39dqWdimKW4r1L8TYKqA=; b=HkH3vt0kFTiJBds/OZKWRCNqtDu2w1l6ec+3E8dB1YZQeJVTZGUBdH9nMXIAZBOrEP jENvZsAgc8SMEa6bh4gAbmPQthlXbSBKpgDjnHUSNC6l39XnphMieY556bEzcTxeUOSa oGqppzLk3EEf9JeuGXUpYaxDLjgv+NsOyTV2iX9VShjwM6N6ObnoCOBYXi/8gO/Qt3VK OSZctinP8kX2dTFX1b54cM73I0WmXob4aQY/l9599H0l/Fs2tUG2xNiEP4Pb7reGAz95 CJga18fG6WHCCvjEp5tz8wLpxG2YRz9yK+opxv6gMHixKlbWUQgWW0oOo+Yh/ft6+eEt PH8Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pfzsU4hU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s8-20020a0562140ca800b0053192698a17si12322183qvs.547.2023.01.03.10.27.49 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:27:49 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=pfzsU4hU; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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)); for (n = 0; n < BCM283X_NCPUS; n++) { - /* TODO: this should be converted to a property of ARM_CPU */ - s->cpu[n].core.mp_affinity = (bc->clusterid << 8) | n; + if (!object_property_set_int(OBJECT(&s->cpu[n].core), "mp-affinity", + (bc->clusterid << ARM_AFF1_SHIFT) | n, + errp)) { + return; + } /* set periphbase/CBAR value for CPU-local registers */ if (!object_property_set_int(OBJECT(&s->cpu[n].core), "reset-cbar", From patchwork Tue Jan 3 18:16:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638764 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1394932pvb; Tue, 3 Jan 2023 10:29:34 -0800 (PST) X-Google-Smtp-Source: AMrXdXvRUq2ik7uoSd8XoWB5FdCWS7ItXY5jZAV70u/t7HXrGE+GFtOzzc+HYEZttT/SuPpWpVeB X-Received: by 2002:ad4:55cf:0:b0:531:c3ab:a8af with SMTP id bt15-20020ad455cf000000b00531c3aba8afmr12858997qvb.41.1672770574478; Tue, 03 Jan 2023 10:29:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770574; cv=none; d=google.com; s=arc-20160816; b=QHKdPxu+qJLYLdMT29uNI0O0bzU5sFr9AWE41lnllpH/gq/6Ypn0pT47lrwZC2S5xk cvCzC/+kz67+3AvGKBZccqpdo0lWrhubkxX6Moci1pIhK8HU3/tizqjt1sgrfAuN+aCf baPToyTR9VLt8y4t9Fx5vzkk5EEPrFgi1ChYHDYnTL/7CGW9krUMa/PmSxdzuH5zehCa LzaOXSo0yZscryvIlXsB1/fy1jcDlwwjzop0oz0kqWM/gHxwgetMeXm8+qmTkAlfgXn7 NgBZ63f73dvBC9hZj+buq2maLRFtPLRxGtEQ7XPKlwNiU5HcHux9raNHgy60gKZUj2AW ROMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JCltR3KinAgd2uF6C+01owj+mYF2uDzhF9nMarGDJGo=; b=cOznIUJlgXMVXV24FKkrcIAymo+bF7T3MQfenbZ83FN0zbfG835M05LQAWoPdh0zzI tAQzIAKNn51QnGDGTY20yLlCarptq5ZL/dYihN7m+feVSRwJn1gsz8THeU6s4iEn7kwI UQd3rD36A2IYm6w4sZz3eHxogXCyMfW+TXT/Vkq9+ox/5G1nbfkvZncQB94I9jUGom6N nw65Fda6OUfogyKbFtK2sQcB/zIHoNablzAqXwMfAKEFZnqcmvmLztSo0Owc2Hz3mP5L hrIwLsR1YSVsM+zbfwOKA0Ctu8d7J/oUZ6UJ80NKkWcvGElE8GcuH3f2wTpVHoFEytoU YdfA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X+zQqDX8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id gf6-20020a056214250600b00531b23a5070si7253544qvb.256.2023.01.03.10.29.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:29:34 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=X+zQqDX8; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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 { unsigned int gt_cntfrq_period_ns(ARMCPU *cpu); -uint64_t arm_cpu_mp_affinity(int idx, uint8_t clustersz); +uint64_t arm_build_mp_affinity(int idx, uint8_t clustersz); #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 **errp) /* CPUs */ for (i = 0; i < nc->num_cpus; i++) { object_property_set_int(OBJECT(&s->cpu[i]), "mp-affinity", - arm_cpu_mp_affinity(i, NPCM7XX_MAX_NUM_CPUS), + arm_build_mp_affinity(i, NPCM7XX_MAX_NUM_CPUS), &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 = ARM_DEFAULT_CPUS_PER_CLUSTER; - return arm_cpu_mp_affinity(idx, clustersz); + return arm_build_mp_affinity(idx, clustersz); } /* 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 = GICV3_TARGETLIST_BITS; } } - return arm_cpu_mp_affinity(idx, clustersz); + return arm_build_mp_affinity(idx, clustersz); } 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) } } -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 = idx / clustersz; uint32_t Aff0 = idx % clustersz; @@ -1927,8 +1927,8 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) * so these bits always RAZ. */ if (cpu->mp_affinity == ARM64_AFFINITY_INVALID) { - cpu->mp_affinity = arm_cpu_mp_affinity(cs->cpu_index, - ARM_DEFAULT_CPUS_PER_CLUSTER); + cpu->mp_affinity = arm_build_mp_affinity(cs->cpu_index, + ARM_DEFAULT_CPUS_PER_CLUSTER); } if (cpu->reset_hivecs) { From patchwork Tue Jan 3 18:16:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638727 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1390842pvb; Tue, 3 Jan 2023 10:18:51 -0800 (PST) X-Google-Smtp-Source: AMrXdXumANWSFQPakS3l49qp+pOOmh+dwD6TrnA88wrMy6ipbDSeqK9aOv4ujSsRh/AkNGS9OVjt X-Received: by 2002:ac8:67d0:0:b0:3a7:f944:b657 with SMTP id r16-20020ac867d0000000b003a7f944b657mr64171926qtp.59.1672769930840; Tue, 03 Jan 2023 10:18:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672769930; cv=none; d=google.com; s=arc-20160816; b=EHuzOnZzy5pvXCFsy8CuRhL2/KlWLeKxjqeIUnlPb6RcCEgcY52LVyDqZKW+HRK7NQ 6YlygbbZQG54C+8J7/2L4hi9FCALYkxCankszMxL8n/G3RWlxpKPMqJbZ7kY0kLeCfGW +9LhVxzzBrvqdNkavOBiWUYytoo3LHgw9zdSi8XywOsDOSbfkZ0v/6YfVFUCFcTzXmd/ YhFoPXVD67s7KX2WbN1yDRD4+ifn84xcHuy6TE2YT8/ocFEsvnBMGr8X9TOp9LVk9+gA XDhHoCRyvtBeE5UKnQMgP4RsDCqhihcgfMyOjAHK/uuB473L/y85Fbc6xcPhlgTdvMtt 72eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Pmw60XZJkaURtg8eJBBrSmnGqjJDvsMLyRzbxcUBtvE=; b=cieldCQlaOQHrZacu12LteuU1/iDcVPHCLK78G4PQhO8cGxiawnAraB9F2WW0IMO4e /jhTWH2n8DFX3UcOlzwQUkLjJ1euehahTqwYyz4KfmcBjFAuDsvu8VX8JRSMm/BTaGS1 v+yzfabEGAbQHlOUxOdwDTmZ1P71LB1v8fwZnUZmXubSULZV+0qpAXFjCrOkhRKrZk6m N7xsUkKrv5iQDOdb7YpSrTSNjCtDJlztTYAm7D2l/NolChUeCBJ6tGhhUE7OuOh1T+L8 Is0/2tKlfIB7YNBUPFhH4Z1C6JoHExuDnH629Adlr8YMFLoLqoNQ5GRb5969wsP20P7i 7gRQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qm55UOU3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id d25-20020ac85459000000b003a695184f21si16493409qtq.235.2023.01.03.10.18.50 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:18:50 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qm55UOU3; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Wrapper to return the mp affinity bits from the cpu. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- 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); uint64_t arm_build_mp_affinity(int idx, uint8_t clustersz); +static inline uint64_t arm_cpu_mp_affinity(ARMCPU *cpu) +{ + return cpu->mp_affinity; +} + #ifndef CONFIG_USER_ONLY extern const VMStateDescription vmstate_arm_cpu; 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, VirtMachineState *vms) build_append_int_noprefix(table_data, vgic_interrupt, 4); build_append_int_noprefix(table_data, 0, 8); /* GICR Base Address*/ /* 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 *vms) for (cpu = 0; cpu < smp_cpus; cpu++) { ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(cpu)); - if (armcpu->mp_affinity & ARM_AFF3_MASK) { + if (arm_cpu_mp_affinity(armcpu) & ARM_AFF3_MASK) { addr_cells = 2; break; } @@ -418,10 +418,10 @@ static void fdt_add_cpu_nodes(const VirtMachineState *vms) if (addr_cells == 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)); } 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 psci_conduit) ARMCPU *armcpu = ARM_CPU(qemu_get_cpu(i)); 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 != 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 *armcpu, 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)); } } 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 = ARM_CPU(cpu); - if (armcpu->mp_affinity == id) { + if (arm_cpu_mp_affinity(armcpu) == 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, static void hvf_psci_cpu_off(ARMCPU *arm_cpu) { - int32_t ret = arm_set_cpu_off(arm_cpu->mp_affinity); + int32_t ret = arm_set_cpu_off(arm_cpu_mp_affinity(arm_cpu)); assert(ret == QEMU_ARM_POWERCTL_RET_SUCCESS); } @@ -674,7 +674,7 @@ static bool hvf_handle_psci_call(CPUState *cpu) int32_t ret = 0; trace_hvf_psci_call(param[0], param[1], param[2], param[3], - arm_cpu->mp_affinity); + arm_cpu_mp_affinity(arm_cpu)); 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; cpu_off: - ret = arm_set_cpu_off(cpu->mp_affinity); + ret = arm_set_cpu_off(arm_cpu_mp_affinity(cpu)); /* notreached */ /* sanity check in case something failed */ assert(ret == QEMU_ARM_POWERCTL_RET_SUCCESS); From patchwork Tue Jan 3 18:16:22 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638749 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1393075pvb; Tue, 3 Jan 2023 10:24:48 -0800 (PST) X-Google-Smtp-Source: AMrXdXv0g0rrHXnMyCTV+uBw9cDt4paCt/Hksq6+ei1KeBZKvzUsKVqHAANO/CKks4msyugn8wKq X-Received: by 2002:a05:622a:4c88:b0:3a8:21a5:d93 with SMTP id ez8-20020a05622a4c8800b003a821a50d93mr71972995qtb.39.1672770287911; Tue, 03 Jan 2023 10:24:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770287; cv=none; d=google.com; s=arc-20160816; b=pyj4rxyuW/HsbDWLG+LXIQ3b03B4fKNwmHP1M/5a+w6sIQdhJKTBKhwOU3u0k1IvhO L+vGwT6HgPxDAO9uwI3mHo/mzdt+Jhz+OKFQwhWSL0RGbDczOGe1/AUMRBWGAsAuPAJr 6RxUoxVX5cwA+1V4EvVOGO2WSqhx8QhXXIn+pmMcWhQDt8lcPafmUfoEGolCRt9A22ca BnXISqdp3LjETYJOALyxxF+ZHZBPh8bqZAnKeiX5WDgGajsXkGQ2TMVhTDyM7GSpokaL /gMTRWmZ78RqWoEa7UtypXo7cFKI/C8Ur69C1hKgEdwCAr2aCW9+SSS5WoE7P8hw4IcL xTPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=jHRFXnO9//MOeiq7qjJkKcDR9svz35fK7EmJ2XSeXDU=; b=bZSCGA3jkXz7pY0AESHfjLMZoZzhlt+WkYvcZps+247KiroEMqwTZ/kRmwpdD+h9r3 /m+oggRzWlbJG3KqHRx/TIM3XUHpg7gnDhHLxiPFSZ04IVgkf+Qkc1G5AJ0lEYCKsk/L kuaM0hsqddKU7z35TvCwTnQspvrCH2+KsFE48p0yowmFxUN6b3Kbj/qXhB5rE+ubiJpd 6BswAZEv8OV+vyH/0AWQaMVIxpZQdzuLcHnO0hAOEanD4YjqOsEvs45RTNsT61i03ZC1 SwC18aqNp/LunntkuJXPF6aZbLajqubXQsK6l7Re9xogf32OOHsLjvqbivJRDYnBJGjA UuSA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gyNggrmq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bq34-20020a05620a46a200b006fa3068e782si16516708qkb.414.2023.01.03.10.24.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:24:47 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=gyNggrmq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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; - /* Uniprocessor system with MP extensions */ - bool mp_is_up; - /* True if we tried kvm_arm_host_cpu_features() during CPU instance_init * 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 clustersz); static inline uint64_t arm_cpu_mp_affinity(ARMCPU *cpu) { - return cpu->mp_affinity; + return cpu->mpidr_el1 & ARM64_AFFINITY_MASK; } #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 = 2; # endif #else + /* To be set properly by either the board or by realize. */ + cpu->mpidr_el1 = 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, Error **errp) return; } - /* This cpu-id-to-MPIDR affinity is used only for TCG; KVM will override 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 fields, - * so these bits always RAZ. - */ - if (cpu->mp_affinity == ARM64_AFFINITY_INVALID) { - cpu->mp_affinity = arm_build_mp_affinity(cs->cpu_index, - ARM_DEFAULT_CPUS_PER_CLUSTER); - } - if (cpu->reset_hivecs) { cpu->reset_sctlr |= (1 << 13); } @@ -2116,7 +2109,27 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) if (cpu->core_count == -1) { cpu->core_count = 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 == ARM64_AFFINITY_INVALID) { + assert(!kvm_enabled()); + assert(cs->cpu_index < 256 * ARM_DEFAULT_CPUS_PER_CLUSTER); + cpu->mpidr_el1 = arm_build_mp_affinity(cs->cpu_index, + ARM_DEFAULT_CPUS_PER_CLUSTER); + } +#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 |= (1u << 31); /* M */ + if (cpu->core_count == 1) { + cpu->mpidr_el1 |= 1 << 30; /* U */ + } + } if (tcg_enabled()) { int dcz_blocklen = 4 << cpu->dcz_blocksize; @@ -2176,10 +2189,47 @@ static ObjectClass *arm_cpu_class_by_name(const char *cpu_model) return oc; } +static void cpu_arm_set_mp_affinity(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + ARMCPU *cpu = ARM_CPU(obj); + CPUARMState *env = &cpu->env; + uint64_t value; + + if (!visit_type_uint64(v, name, &value, errp)) { + return; + } + + if (arm_feature(env, ARM_FEATURE_AARCH64)) { + value &= ARM64_AFFINITY_MASK; + } else { + value &= ARM32_AFFINITY_MASK; + } + if (cpu->mpidr_el1 == ARM64_AFFINITY_INVALID) { + cpu->mpidr_el1 = value; + } else { + cpu->mpidr_el1 &= ~ARM64_AFFINITY_MASK; + cpu->mpidr_el1 |= value; + } +} + +static void cpu_arm_get_mp_affinity(Object *obj, Visitor *v, const char *name, + void *opaque, Error **errp) +{ + ARMCPU *cpu = 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 = cpu->mpidr_el1 & ARM64_AFFINITY_MASK; + visit_type_uint64(v, name, &value, errp); +} + static Property arm_cpu_properties[] = { 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) device_class_set_props(dc, arm_cpu_properties); + 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); 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 = 0x0010142; cpu->isar.id_isar5 = 0x0; cpu->isar.id_isar6 = 0x0; - cpu->mp_is_up = true; cpu->pmsav7_dregion = 16; cpu->isar.reset_pmcr_el0 = 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 ARMCPRegInfo *ri) return raw_read(env, ri); } -static uint64_t mpidr_read_val(CPUARMState *env) -{ - ARMCPU *cpu = env_archcpu(env); - uint64_t mpidr = cpu->mp_affinity; - - if (arm_feature(env, ARM_FEATURE_V7MP)) { - mpidr |= (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 |= (1u << 30); - } - } - return mpidr; -} - static uint64_t mpidr_read(CPUARMState *env, const ARMCPRegInfo *ri) { unsigned int cur_el = arm_current_el(env); @@ -4112,7 +4094,7 @@ static uint64_t mpidr_read(CPUARMState *env, const ARMCPRegInfo *ri) if (arm_is_el2_enabled(env) && cur_el == 1) { return env->cp15.vmpidr_el2; } - return mpidr_read_val(env); + return env_archcpu(env)->mpidr_el1; } static const ARMCPRegInfo lpae_cp_reginfo[] = { @@ -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 = mpidr_read_val(env); ARMCPRegInfo vpidr_regs[] = { { .name = "VPIDR", .state = ARM_CP_STATE_AA32, .cp = 15, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0, @@ -7956,12 +7937,12 @@ void register_cp_regs_for_features(ARMCPU *cpu) { .name = "VMPIDR", .state = ARM_CP_STATE_AA32, .cp = 15, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5, .access = PL2_RW, .accessfn = access_el3_aa32ns, - .resetvalue = vmpidr_def, + .resetvalue = cpu->mpidr_el1, .type = ARM_CP_ALIAS | ARM_CP_EL3_NO_EL2_C_NZ, .fieldoffset = offsetoflow32(CPUARMState, cp15.vmpidr_el2) }, { .name = "VMPIDR_EL2", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 5, - .access = PL2_RW, .resetvalue = vmpidr_def, + .access = PL2_RW, .resetvalue = cpu->mpidr_el1, .type = ARM_CP_EL3_NO_EL2_C_NZ, .fieldoffset = 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); ret = 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); ret = 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 = kvm_get_one_reg(cs, ARM64_SYS_REG(ARM_CPU_ID_MPIDR), &mpidr); + ret = kvm_get_one_reg(cs, ARM64_SYS_REG(ARM_CPU_ID_MPIDR), + &cpu->mpidr_el1); if (ret) { return ret; } - cpu->mp_affinity = mpidr & ARM64_AFFINITY_MASK; kvm_arm_init_debug(cs); From patchwork Tue Jan 3 18:16:23 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638736 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1391494pvb; Tue, 3 Jan 2023 10:20:30 -0800 (PST) X-Google-Smtp-Source: AMrXdXvd5Zb9HVKAv+voK/oQueApesayiptU7W3GdYPF0gvjMGew1O7QyBg4HIMS9vr4WGbCHoqn X-Received: by 2002:a05:622a:244a:b0:3a8:27b9:5e18 with SMTP id bl10-20020a05622a244a00b003a827b95e18mr71798327qtb.67.1672770029972; Tue, 03 Jan 2023 10:20:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770029; cv=none; d=google.com; s=arc-20160816; b=M4mBcgYDOEQyFWcZVjOnRm7SY/fUcEi8aOA9l/6Xz/2PNMOjq7IOTXbTgEOzOpkma4 OzWb3AdMiPlhpSwOEZKWZah8UJ773wTlo4FwzS4HfeoP3ZUqdegBwvruOmTDXf8hI69M 81b9GIm0a3bqD+JUoHC1q2fW8/zOgccZrInToOGkqyFUSmD3uONjZHm2PIagX2/dJopn rDpyeRg75mG/W4zSQLKdcRCmGOeyPNv4IBNxwB+7TnaRq9NlWpzAe89YyyFSh0lxh8vm z+nux0cg5LOWt5yVLBp+GIJoemDx0REWxfttG/t3dyUvlLVkWChraFiF8lzvBedDRYMs x0Ww== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Wyr5V1dWDMqzJtGPzngC+jk55ZVA++3QMCuRXKZqttA=; b=FhPegaYVG5B3D8TTIBLmzTEvTsDK2H3P9NCQUofSs7+g7Kbrv4rGVndJq7IPDe0AVy 1q2En47wjkpv/I0XwF3wx4BY8JD+j/hXQBskvqoQMQrLdvoNLvuEGxmUj92qJweVnpED ZkyY2FFDxjHrZTORJRMR+62i3aCnxDlRUxetw8l0A8JSDhUgAC8K8bdsSeX4to41e9jh XbR1wZ0jQqKErcfKy3j2XI8YTssN13BTT1fuj9EENrU0G0NBPu43jXPTrgKKqkN8irx2 eaK1VSxeqZQopaoyENvwxHem+WV+Ukk3IRWs+ia/+tXoL7wlx5TktZuJ2RjOrB/qSr/E gyDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kq6RkKmG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id l24-20020ac87258000000b00397ce0788ffsi16040853qtp.525.2023.01.03.10.20.29 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:20:29 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Kq6RkKmG; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrg-0000Li-JX; Tue, 03 Jan 2023 13:18:20 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1pClr5-0008KT-1n for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:45 -0500 Received: from mail-vk1-xa2d.google.com ([2607:f8b0:4864:20::a2d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1pClr3-0005FO-Gh for qemu-devel@nongnu.org; Tue, 03 Jan 2023 13:17:42 -0500 Received: by mail-vk1-xa2d.google.com with SMTP id f184so11693113vkh.2 for ; Tue, 03 Jan 2023 10:17:41 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Wyr5V1dWDMqzJtGPzngC+jk55ZVA++3QMCuRXKZqttA=; b=Kq6RkKmGAD4JxZwhoyY+Iee5QDYces8Mf405BzHxPBOoVc3qcFn0X7wa0Q8aZB+RMb 4qnSG+7EA2uGHlBSEtj84zQDzo1bCEyr3kgPmz/4rfFwfaMn6hS5qLveO5JZ5fMb3lab dfCe8JqEA5Mk1PLMgvOKp8ymvoKDE4pn0ZHY1QLOXOon0vvSyHuWrORuQgiA8t1XhW7/ C2ZHNrunlOdlCQoaA9ydXa77+uMYzqDRCWv/MUxqgs2sGVE69h/lQWa4yA0uPBFH8IMD YJ2tdutKUgenjvwzsoyN2yg2STVn4zm+IjTUvh3zNUHwebVXQ7ke//FAXBNh5l6zR5SC KkrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Wyr5V1dWDMqzJtGPzngC+jk55ZVA++3QMCuRXKZqttA=; b=L53i9OVtvt+H0W2h9rjcS7IdvOyk49JMRFPEwKmNba+xbb65NgRYOiu+93Sr4t50pp ijCXxdvVx6iErCeDsVg5IG1dBbPoNZNyLXRurOi4y+Vtz2JcxRFqwLJQgh6BdP4L8Kjx bw57/dSC8nO7//7YAw70GGIY4xtTQd5zGwRTs/bWbJhFWVrUqFA3z+4pV0abA/HwvY9r aAcBYZlXI+7JE+1R936NAgzipX5pwXF2eQ39616QdFNRDFMFBxlrcKGu8z8qiO+KhUh1 q8uVdvRtPrdWp4oY+S6QW57LUdWo8sdNSWoK86zrEQJUme4lsLUaVOAEU/FbuVVx+zsl iISg== X-Gm-Message-State: AFqh2kqnVxdIdDxq3ZsaF3Q8j6kM5v9MvFogPFvP7TW1xxVGlJuiZLvv xw5HWjp5pI6IInB5wL30dKSzqCwCdbZOKLbzIH0= X-Received: by 2002:a1f:24ce:0:b0:3d5:5cd4:8835 with SMTP id k197-20020a1f24ce000000b003d55cd48835mr13557926vkk.15.1672769860366; Tue, 03 Jan 2023 10:17:40 -0800 (PST) Received: from stoup.. ([2607:fb90:8060:51a2:184b:6e49:c396:be2]) by smtp.gmail.com with ESMTPSA id v2-20020a05620a440200b006fed2788751sm23042354qkp.76.2023.01.03.10.17.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 03 Jan 2023 10:17:39 -0800 (PST) From: Richard Henderson To: qemu-devel@nongnu.org Cc: pbonzini@redhat.com, berrange@redhat.com, eduardo@habkost.net, armbru@redhat.com, ajones@ventanamicro.com, alex.bennee@linaro.org Subject: [RFC PATCH 17/40] target/arm: Copy cp_regs from ARMCPUClass Date: Tue, 3 Jan 2023 10:16:23 -0800 Message-Id: <20230103181646.55711-18-richard.henderson@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230103181646.55711-1-richard.henderson@linaro.org> References: <20230103181646.55711-1-richard.henderson@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2607:f8b0:4864:20::a2d; envelope-from=richard.henderson@linaro.org; helo=mail-vk1-xa2d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Create a hash table of cpregs in ARMCPUClass and copy to the instance in arm_cpu_init. Population of this new table will come in a future patch. Signed-off-by: Richard Henderson --- target/arm/cpu-qom.h | 3 +++ target/arm/cpu.c | 23 +++++++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/target/arm/cpu-qom.h b/target/arm/cpu-qom.h index 832b2cccf9..36d7fa9779 100644 --- a/target/arm/cpu-qom.h +++ b/target/arm/cpu-qom.h @@ -111,6 +111,9 @@ struct ARMCPUClass { DeviceRealize parent_realize; ResettablePhases parent_phases; + /* Coprocessor information */ + GHashTable *cp_regs; + /* 'compatible' string for this CPU for Linux device trees */ const char *dtb_compatible; diff --git a/target/arm/cpu.c b/target/arm/cpu.c index a46fa424d3..da58f1fae7 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1178,14 +1178,29 @@ uint64_t arm_build_mp_affinity(int idx, uint8_t clustersz) return (Aff1 << ARM_AFF1_SHIFT) | Aff0; } +static void copy_cp_regs_1(gpointer key, gpointer value, gpointer user) +{ + GHashTable *new_table = user; + ARMCPRegInfo *new_reg = g_memdup(value, sizeof(ARMCPRegInfo)); + bool ok = g_hash_table_insert(new_table, key, new_reg); + g_assert(ok); +} + +static GHashTable *copy_cp_regs(GHashTable *cp_regs) +{ + GHashTable *ret = g_hash_table_new_full(g_direct_hash, g_direct_equal, + NULL, g_free); + + g_hash_table_foreach(cp_regs, copy_cp_regs_1, ret); + return ret; +} + static void arm_cpu_initfn(Object *obj) { ARMCPU *cpu = ARM_CPU(obj); ARMCPUClass *acc = ARM_CPU_GET_CLASS(cpu); cpu_set_cpustate_pointers(cpu); - cpu->cp_regs = g_hash_table_new_full(g_direct_hash, g_direct_equal, - NULL, g_free); QLIST_INIT(&cpu->pre_el_change_hooks); QLIST_INIT(&cpu->el_change_hooks); @@ -1219,6 +1234,8 @@ static void arm_cpu_initfn(Object *obj) cpu->gic_pribits = acc->gic_pribits; cpu->kvm_target = acc->kvm_target; + cpu->cp_regs = copy_cp_regs(acc->cp_regs); + #ifdef CONFIG_USER_ONLY # ifdef TARGET_AARCH64 /* @@ -2337,6 +2354,8 @@ static void arm_cpu_leaf_class_init(ObjectClass *oc, void *data) const ARMCPUInfo *info = data; acc->info = info; + acc->cp_regs = g_hash_table_new_full(g_direct_hash, g_direct_equal, + NULL, g_free); if (info->class_init) { info->class_init(acc); } From patchwork Tue Jan 3 18:16:24 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638746 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1392764pvb; Tue, 3 Jan 2023 10:23:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXtyPg4YkT4AYWa4M2T2UN2XltXhPL9TZC39h+C6ST7F4nHBGvL7WCLUOvLpHMC962jJiMk2 X-Received: by 2002:ac8:4742:0:b0:3a8:16d:ea4c with SMTP id k2-20020ac84742000000b003a8016dea4cmr74679688qtp.31.1672770237601; Tue, 03 Jan 2023 10:23:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770237; cv=none; d=google.com; s=arc-20160816; b=TdCEypmMwfRkm3RtK5I/3szWcACzo2fW7kkKxbz5oHt88Nk42t4sHJVuKMv5hUQbGN tYeidXZGW6baGY0i3HHOmeX9bOi0CmDjqk5xdvmODYLRoj4Wvd+O2lcYQJzSdqbmHzAN EswifMHRR0rES+HqwGn/Q2U2JHM6pQ5gJFdqp+jUYTbyFxZq7UT1zcaP/1OZbPdnVBW6 aNJkkyhsnbuG0dxmgmNXXYUBDD3HJ7BzyGqyjbznvJYrLEAcq0V/al30yysHXq9NRF3s 9i7hQuPg4jJ58JUrhFM2AhDOx4qVT+0X9sDFm8RIQgTRXpKAWPOCY/TJI2me2ldTodQu W94A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ovrzlFU5k82ZgCppHjlpfiJtVNxGU+QnnGdphNskZzQ=; b=Mm89Y/yunPbF85F0zparI8vHP70DDbvSYYQcvh5lPRtuFk24oNZWuwU7OmRYrVThaK MzpaiY97yvWd0NzF/rdjVi2IaJr4+BKXLLfY2y/hR3HZMv2aLA3lH8konQIT52TC3MPk xaDNBSBnrIntnNJFCnaf4A8FpZFYad/KfDlk5v+QdqmnbQeaeJlbN1OAb6WxTkA8vT61 Z7mC4lPcByAH9ZGnzn8xQIabJ5lyLfOTkz8WrUC44hGzA/HOm7y3xb5nHhdYVCGDKp/B QdGvJP2sFWUKQXEnkM7Oad6EIBoVbUzEfGDC+zzrKQgFSmeLnW6WMM72EzUtl9M0D2XU Xlhg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NX0fx278; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q28-20020a05620a2a5c00b006feba0ab910si17685244qkp.609.2023.01.03.10.23.57 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:23:57 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NX0fx278; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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)) -void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, const ARMCPRegInfo *reg, - void *opaque); +void define_one_arm_cp_reg_with_table(GHashTable *cp_regs, uint64_t features, + const ARMCPRegInfo *reg, void *opaque); + +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); +} static inline void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs) { define_one_arm_cp_reg_with_opaque(cpu, regs, NULL); } -void define_arm_cp_regs_with_opaque_len(ARMCPU *cpu, const ARMCPRegInfo *regs, - 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); +} #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, const ARMCPRegInfo *regs, #define define_arm_cp_regs(CPU, REGS) \ define_arm_cp_regs_with_opaque(CPU, REGS, NULL) +#define define_arm_cp_regs_with_class(ACC, REGS, OPAQUE) \ + do { \ + QEMU_BUILD_BUG_ON(ARRAY_SIZE(REGS) == 0); \ + ARMCPUClass *acc_ = (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 encoded_cp); /* 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(Error **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 = &cpu->env; uint32_t key; ARMCPRegInfo *r2; bool is64 = r->type & ARM_CP_64BIT; @@ -8541,6 +8541,7 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, int cp = r->cp; size_t name_len; bool make_const; + bool have_el2; switch (state) { case ARM_CP_STATE_AA32: @@ -8569,7 +8570,7 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, /* Overriding of an existing definition must be explicitly requested. */ if (!(r->type & ARM_CP_OVERRIDE)) { - const ARMCPRegInfo *oldreg = get_arm_cp_reginfo(cpu->cp_regs, key); + const ARMCPRegInfo *oldreg = 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, const ARMCPRegInfo *r, * feature into the same ARMCPRegInfo array and define them all at once. */ make_const = false; - if (arm_feature(env, ARM_FEATURE_EL3)) { + have_el2 = 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 = ctz32(r->access) / 2; - if (min_el == 2 && !arm_feature(env, ARM_FEATURE_EL2)) { + if (min_el == 2 && !have_el2) { if (r->type & ARM_CP_EL3_NO_EL2_UNDEF) { return; } make_const = !(r->type & ARM_CP_EL3_NO_EL2_KEEP); } } else { - CPAccessRights max_el = (arm_feature(env, ARM_FEATURE_EL2) - ? PL2_RW : PL1_RW); + CPAccessRights max_el = have_el2 ? PL2_RW : PL1_RW; if ((r->access & max_el) == 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 == ARM_CP_STATE_BOTH && ns) || - (arm_feature(env, ARM_FEATURE_V8) && !ns)) { + ((features & (1ull << ARM_FEATURE_V8)) && !ns)) { r2->type |= ARM_CP_ALIAS; } } else if ((secstate != r->secure) && !ns) { @@ -8720,12 +8721,11 @@ static void add_cpreg_to_hashtable(ARMCPU *cpu, const ARMCPRegInfo *r, assert(!raw_accessors_invalid(r2)); } - g_hash_table_insert(cpu->cp_regs, (gpointer)(uintptr_t)key, r2); + g_hash_table_insert(cp_regs, (gpointer)(uintptr_t)key, r2); } - -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 features, + 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 >= 14 && r->cp <= 15); } else { assert(r->cp < 8 || (r->cp >= 14 && r->cp <= 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, opc2, r->name); break; case ARM_CP_SECSTATE_BOTH: name = 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->name); break; @@ -8889,7 +8892,8 @@ void define_one_arm_cp_reg_with_opaque(ARMCPU *cpu, } else { /* AArch64 registers get mapped to non-secure instance * 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, } /* Define a whole list of registers */ -void define_arm_cp_regs_with_opaque_len(ARMCPU *cpu, const ARMCPRegInfo *regs, - 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 = 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, opaque); } } From patchwork Tue Jan 3 18:16:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638739 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1391923pvb; Tue, 3 Jan 2023 10:21:36 -0800 (PST) X-Google-Smtp-Source: AMrXdXsQSXyRWSb2lsN0GEYFtw/h1r3a0URnmktRbZfgcfAQa7sdVsG2Bubh0eMM5VTEdHOLPHP/ X-Received: by 2002:ac8:5310:0:b0:3a5:c7d9:1607 with SMTP id t16-20020ac85310000000b003a5c7d91607mr59228399qtn.52.1672770095750; Tue, 03 Jan 2023 10:21:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770095; cv=none; d=google.com; s=arc-20160816; b=uhrA1y2MioHrsqKOcuDKKclp8GRIECZle7Zr2DWh1dgMGBNtnrRaPowor+3KHqj4tm JAmpYN0k2di/bD7/2OF0t/QsEQ9xoMg05bvxJs/vHbb875plvTmHeOh22/B1ae40coQ2 3EOEHwQos0fskUtlwKrU5mR55HRWuwLNNx3LDV61/eU0E4OWD15Xn4CrBSmOi7gt1voW 1mx4NxFhFMyy+GPxiQ2rzPV+GWyJx9DF5fbCHjk21TJ7Q1ndMoqs/eOjktbAWjhEVIWY Qj2NDl0uoFha0Ji6FoHNNseATzovgQrle/JpGO1rvxZPSz4tpgst69RX1jkObzvI0/y7 LeFg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=zAFkjIGv2XqewT6+4Aqot8thaYlSpZ+Y95cRcOD0ZRc=; b=Ewhk+QPyKBMNHU2VIgAbQHK5Vgx9NZiuMsDA4VpfneWVJaQy84fSmoZG3/THkqbSR0 GHfBE2qAbz3Vtc/bFTii2g7BvO4iiT2I2eth3fmdypmiJyRYd/HfgNc5WCLDke7Z75n+ 3j1Wj+GfHVelJqauqInzw40XHiK3II1nEnWHaEtm73yyRhT2StmsJnaNHB73CVAAiSmy fG/LDJBQYLdXDSNR1E2rOHtu2+fTrRFb316+mu9sn4LA4DKqRMeveimZoQ5LsACk7HrN Gc84Auc2nOnRlJO9PMqXJU19tBISAHKRdf4V+gh/JN9PbZI28rOqb0osbkh8MJIVvVIR OTKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HZNZBFb2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m17-20020ac84451000000b003a575e96db5si15745822qtn.10.2023.01.03.10.21.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:21:35 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=HZNZBFb2; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1pClrg-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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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) 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; 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 **errp); #endif #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 bool el_is_in_host(CPUARMState *env, int el); -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, void *data) static void arm_cpu_leaf_class_init(ObjectClass *oc, void *data) { ARMCPUClass *acc = ARM_CPU_CLASS(oc); - const ARMCPUInfo *info = data; - acc->info = info; acc->cp_regs = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free); - if (info->class_init) { - info->class_init(acc); + + acc->info = data; + if (acc->info->class_init) { + acc->info->class_init(acc); } } +static bool arm_cpu_class_late_init(ObjectClass *oc, Error **errp) +{ + ARMCPUClass *acc = 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 = { .parent = parent, .instance_size = sizeof(ARMCPU), .instance_align = __alignof__(ARMCPU), - .instance_init = info->initfn, + .instance_init = info->object_init, .class_size = sizeof(ARMCPUClass), .class_init = arm_cpu_leaf_class_init, .class_data = (void *)info, @@ -2389,6 +2401,7 @@ static const TypeInfo arm_cpu_type_info = { .abstract = true, .class_size = sizeof(ARMCPUClass), .class_init = arm_cpu_class_init, + .class_late_init = arm_cpu_class_late_init, }; 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" -static void aarch64_a35_initfn(Object *obj) +static void aarch64_a35_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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); /* From B2.2 AArch64 identification registers. */ cpu->midr = 0x411fd040; @@ -678,19 +676,17 @@ void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp) cpu->isar.id_aa64mmfr0 = t; } -static void aarch64_a57_initfn(Object *obj) +static void aarch64_a57_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = QEMU_KVM_ARM_TARGET_CORTEX_A57; cpu->midr = 0x411fd070; cpu->revidr = 0x00000000; @@ -735,19 +731,17 @@ static void aarch64_a57_initfn(Object *obj) define_cortex_a72_a57_a53_cp_reginfo(cpu); } -static void aarch64_a53_initfn(Object *obj) +static void aarch64_a53_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = QEMU_KVM_ARM_TARGET_CORTEX_A53; cpu->midr = 0x410fd034; cpu->revidr = 0x00000000; @@ -792,19 +786,17 @@ static void aarch64_a53_initfn(Object *obj) define_cortex_a72_a57_a53_cp_reginfo(cpu); } -static void aarch64_a55_initfn(Object *obj) +static void aarch64_a55_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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); /* Ordered by B2.4 AArch64 registers by functional group */ cpu->clidr = 0x82000023; @@ -860,19 +852,17 @@ static void aarch64_a55_initfn(Object *obj) cpu->isar.reset_pmcr_el0 = 0x410b3000; } -static void aarch64_a72_initfn(Object *obj) +static void aarch64_a72_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = 0x410fd083; cpu->revidr = 0x00000000; cpu->reset_fpsid = 0x41034080; @@ -915,19 +905,17 @@ static void aarch64_a72_initfn(Object *obj) define_cortex_a72_a57_a53_cp_reginfo(cpu); } -static void aarch64_a76_initfn(Object *obj) +static void aarch64_a76_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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); /* Ordered by B2.4 AArch64 registers by functional group */ cpu->clidr = 0x82000023; @@ -984,18 +972,16 @@ static void aarch64_a76_initfn(Object *obj) cpu->isar.reset_pmcr_el0 = 0x410b3000; } -static void aarch64_a64fx_initfn(Object *obj) +static void aarch64_a64fx_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = 0x461f0010; cpu->revidr = 0x00000000; cpu->ctr = 0x86668006; @@ -1021,31 +1007,33 @@ static void aarch64_a64fx_initfn(Object *obj) cpu->gic_vpribits = 5; cpu->gic_vprebits = 5; cpu->gic_pribits = 5; + cpu->isar.reset_pmcr_el0 = 0x46014040; + + /* TODO: Add A64FX specific HPC extension registers */ +} + +static void aarch64_a64fx_object_init(Object *obj) +{ + ARMCPU *cpu = ARM_CPU(obj); /* The A64FX supports only 128, 256 and 512 bit vector lengths */ aarch64_add_sve_properties(obj); cpu->sve_vq.supported = (1 << 0) /* 128bit */ | (1 << 1) /* 256bit */ | (1 << 3); /* 512bit */ - - cpu->isar.reset_pmcr_el0 = 0x46014040; - - /* TODO: Add A64FX specific HPC extension registers */ } -static void aarch64_neoverse_n1_initfn(Object *obj) +static void aarch64_neoverse_n1_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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); /* Ordered by B2.4 AArch64 registers by functional group */ cpu->clidr = 0x82000023; @@ -1102,7 +1090,7 @@ static void aarch64_neoverse_n1_initfn(Object *obj) cpu->isar.reset_pmcr_el0 = 0x410c3000; } -static void aarch64_host_initfn(Object *obj) +static void aarch64_host_object_init(Object *obj) { #if defined(CONFIG_KVM) ARMCPU *cpu = ARM_CPU(obj); @@ -1120,26 +1108,24 @@ static void aarch64_host_initfn(Object *obj) #endif } -/* -cpu max: if KVM is enabled, like -cpu host (best possible with this host); - * otherwise, a CPU with as many features enabled as our emulation supports. +/* + * -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 = ARM_CPU(obj); uint64_t t; uint32_t u; if (kvm_enabled() || hvf_enabled()) { - /* With KVM or HVF, '-cpu max' is identical to '-cpu host' */ - aarch64_host_initfn(obj); - return; + return true; } /* '-cpu max' for TCG: we currently do this as "A57 with extra things" */ - - aarch64_a57_initfn(obj); + aarch64_a57_class_init(cpu); /* * Reset MIDR so the guest doesn't mistake our 'max' CPU type for a real @@ -1296,6 +1282,18 @@ static void aarch64_max_initfn(Object *obj) cpu->ctr = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */ cpu->dcz_blocksize = 7; /* 512 bytes */ #endif + return true; +} + +static void aarch64_max_object_init(Object *obj) +{ + ARMCPU *cpu = 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; + } cpu->sve_vq.supported = MAKE_64BIT_MASK(0, ARM_MAX_VQ); cpu->sme_vq.supported = SVE_VQ_POW2_MAP; @@ -1309,17 +1307,22 @@ static void aarch64_max_initfn(Object *obj) } static const ARMCPUInfo aarch64_cpus[] = { - { .name = "cortex-a35", .initfn = aarch64_a35_initfn }, - { .name = "cortex-a57", .initfn = aarch64_a57_initfn }, - { .name = "cortex-a53", .initfn = aarch64_a53_initfn }, - { .name = "cortex-a55", .initfn = aarch64_a55_initfn }, - { .name = "cortex-a72", .initfn = aarch64_a72_initfn }, - { .name = "cortex-a76", .initfn = aarch64_a76_initfn }, - { .name = "a64fx", .initfn = aarch64_a64fx_initfn }, - { .name = "neoverse-n1", .initfn = aarch64_neoverse_n1_initfn }, - { .name = "max", .initfn = aarch64_max_initfn }, + { .name = "cortex-a35", .class_init = aarch64_a35_class_init }, + { .name = "cortex-a57", .class_init = aarch64_a57_class_init }, + { .name = "cortex-a53", .class_init = aarch64_a53_class_init }, + { .name = "cortex-a55", .class_init = aarch64_a55_class_init }, + { .name = "cortex-a72", .class_init = aarch64_a72_class_init }, + { .name = "cortex-a76", .class_init = aarch64_a76_class_init }, + { .name = "neoverse-n1", .class_init = aarch64_neoverse_n1_class_init }, + { .name = "a64fx", + .class_init = aarch64_a64fx_class_init, + .object_init = aarch64_a64fx_object_init }, + { .name = "max", + .class_late_init = aarch64_max_class_late_init, + .object_init = aarch64_max_object_init }, #if defined(CONFIG_KVM) || defined(CONFIG_HVF) - { .name = "host", .initfn = aarch64_host_initfn }, + { .name = "host", + .object_init = aarch64_host_object_init }, #endif }; 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 @@ /* Share AArch32 -cpu max features with AArch64. */ -void aa32_max_features(ARMCPU *cpu) +void aa32_max_features(ARMCPUClass *cpu) { uint32_t t; @@ -143,9 +143,9 @@ static const ARMCPRegInfo cortex_a72_a57_a53_cp_reginfo[] = { .access = PL1_RW, .type = ARM_CP_CONST | ARM_CP_64BIT, .resetvalue = 0 }, }; -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 */ @@ -178,14 +178,12 @@ static bool arm_v7m_cpu_exec_interrupt(CPUState *cs, int interrupt_request) } #endif /* !CONFIG_USER_ONLY && CONFIG_TCG */ -static void arm926_initfn(Object *obj) +static void arm926_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = 0x41069265; cpu->reset_fpsid = 0x41011090; cpu->ctr = 0x1dd20d2; @@ -205,28 +203,32 @@ static void arm926_initfn(Object *obj) cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1); } -static void arm946_initfn(Object *obj) +static void arm946_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = 0x41059461; cpu->ctr = 0x0f004006; cpu->reset_sctlr = 0x00000078; } -static void arm1026_initfn(Object *obj) +static void arm1026_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = 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] = { + { .name = "IFAR", .cp = 15, .crn = 6, .crm = 0, .opc1 = 0, .opc2 = 1, + .access = PL1_RW, + .fieldoffset = offsetof(CPUARMState, cp15.ifar_ns), + .resetvalue = 0 } + }; cpu->dtb_compatible = "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 = 0x4106a262; cpu->reset_fpsid = 0x410110a0; cpu->ctr = 0x1dd20d2; @@ -246,21 +248,11 @@ static void arm1026_initfn(Object *obj) cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSP, 1); cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1); - { - /* The 1026 had an IFAR at c6,c0,0,1 rather than the ARMv6 c6,c0,0,2 */ - ARMCPRegInfo ifar = { - .name = "IFAR", .cp = 15, .crn = 6, .crm = 0, .opc1 = 0, .opc2 = 1, - .access = PL1_RW, - .fieldoffset = offsetof(CPUARMState, cp15.ifar_ns), - .resetvalue = 0 - }; - define_one_arm_cp_reg(cpu, &ifar); - } + define_arm_cp_regs_with_class(cpu, ifar, NULL); } -static void arm1136_r2_initfn(Object *obj) +static void arm1136_r2_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = 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) */ cpu->dtb_compatible = "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 = 0x4107b362; cpu->reset_fpsid = 0x410120b4; cpu->isar.mvfr0 = 0x11111111; @@ -296,16 +288,14 @@ static void arm1136_r2_initfn(Object *obj) cpu->reset_auxcr = 7; } -static void arm1136_initfn(Object *obj) +static void arm1136_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = 0x4117b363; cpu->reset_fpsid = 0x410120b4; cpu->isar.mvfr0 = 0x11111111; @@ -327,17 +317,15 @@ static void arm1136_initfn(Object *obj) cpu->reset_auxcr = 7; } -static void arm1176_initfn(Object *obj) +static void arm1176_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = 0x410fb767; cpu->reset_fpsid = 0x410120b5; cpu->isar.mvfr0 = 0x11111111; @@ -359,15 +347,13 @@ static void arm1176_initfn(Object *obj) cpu->reset_auxcr = 7; } -static void arm11mpcore_initfn(Object *obj) +static void arm11mpcore_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = 0x410fb022; cpu->reset_fpsid = 0x410120b4; cpu->isar.mvfr0 = 0x11111111; @@ -395,16 +381,14 @@ static const ARMCPRegInfo cortexa8_cp_reginfo[] = { .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, }; -static void cortex_a8_initfn(Object *obj) +static void cortex_a8_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = 0x410fc080; cpu->reset_fpsid = 0x410330c0; cpu->isar.mvfr0 = 0x11110222; @@ -431,7 +415,7 @@ static void cortex_a8_initfn(Object *obj) cpu->ccsidr[2] = 0xf0000000; /* No L2 icache. */ cpu->reset_auxcr = 2; cpu->isar.reset_pmcr_el0 = 0x41002000; - define_arm_cp_regs(cpu, cortexa8_cp_reginfo); + define_arm_cp_regs_with_class(cpu, cortexa8_cp_reginfo, NULL); } static const ARMCPRegInfo cortexa9_cp_reginfo[] = { @@ -463,22 +447,20 @@ static const ARMCPRegInfo cortexa9_cp_reginfo[] = { .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST }, }; -static void cortex_a9_initfn(Object *obj) +static void cortex_a9_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = 0x410fc090; cpu->reset_fpsid = 0x41033090; cpu->isar.mvfr0 = 0x11110222; @@ -503,7 +485,7 @@ static void cortex_a9_initfn(Object *obj) cpu->ccsidr[0] = 0xe00fe019; /* 16k L1 dcache. */ cpu->ccsidr[1] = 0x200fe019; /* 16k L1 icache. */ cpu->isar.reset_pmcr_el0 = 0x41093000; - define_arm_cp_regs(cpu, cortexa9_cp_reginfo); + define_arm_cp_regs_with_class(cpu, cortexa9_cp_reginfo, NULL); } #ifndef CONFIG_USER_ONLY @@ -529,20 +511,18 @@ static const ARMCPRegInfo cortexa15_cp_reginfo[] = { .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, }; -static void cortex_a7_initfn(Object *obj) +static void cortex_a7_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = QEMU_KVM_ARM_TARGET_CORTEX_A7; cpu->midr = 0x410fc075; cpu->reset_fpsid = 0x41023075; @@ -575,23 +555,23 @@ static void cortex_a7_initfn(Object *obj) cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */ cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */ cpu->isar.reset_pmcr_el0 = 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); } -static void cortex_a15_initfn(Object *obj) +static void cortex_a15_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = QEMU_KVM_ARM_TARGET_CORTEX_A15; /* r4p0 cpu, not requiring expensive tlb flush errata */ cpu->midr = 0x414fc0f0; @@ -622,14 +602,13 @@ static void cortex_a15_initfn(Object *obj) cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */ cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */ cpu->isar.reset_pmcr_el0 = 0x410F3000; - define_arm_cp_regs(cpu, cortexa15_cp_reginfo); + define_arm_cp_regs_with_class(cpu, cortexa15_cp_reginfo, NULL); } -static void cortex_m0_initfn(Object *obj) +static void cortex_m0_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = 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); cpu->midr = 0x410cc200; @@ -658,12 +637,11 @@ static void cortex_m0_initfn(Object *obj) cpu->isar.id_isar6 = 0x00000000; } -static void cortex_m3_initfn(Object *obj) +static void cortex_m3_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = 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 = 0x410fc231; cpu->pmsav7_dregion = 8; cpu->isar.id_pfr0 = 0x00000030; @@ -683,14 +661,12 @@ static void cortex_m3_initfn(Object *obj) cpu->isar.id_isar6 = 0x00000000; } -static void cortex_m4_initfn(Object *obj) +static void cortex_m4_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = 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 = 0x410fc240; /* r0p0 */ cpu->pmsav7_dregion = 8; cpu->isar.mvfr0 = 0x10110021; @@ -713,14 +689,12 @@ static void cortex_m4_initfn(Object *obj) cpu->isar.id_isar6 = 0x00000000; } -static void cortex_m7_initfn(Object *obj) +static void cortex_m7_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = 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 = 0x411fc272; /* r1p2 */ cpu->pmsav7_dregion = 8; cpu->isar.mvfr0 = 0x10110221; @@ -743,15 +717,13 @@ static void cortex_m7_initfn(Object *obj) cpu->isar.id_isar6 = 0x00000000; } -static void cortex_m33_initfn(Object *obj) +static void cortex_m33_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = 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 = 0x410fd213; /* r0p3 */ cpu->pmsav7_dregion = 16; cpu->sau_sregion = 8; @@ -777,16 +749,14 @@ static void cortex_m33_initfn(Object *obj) cpu->ctr = 0x8000c000; } -static void cortex_m55_initfn(Object *obj) +static void cortex_m55_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = 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 = 0x410fd221; /* r0p1 */ cpu->revidr = 0; cpu->pmsav7_dregion = 16; @@ -824,14 +794,12 @@ static const ARMCPRegInfo cortexr5_cp_reginfo[] = { .opc2 = 0, .access = PL1_W, .type = ARM_CP_NOP }, }; -static void cortex_r5_initfn(Object *obj) +static void cortex_r5_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = 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 = 0x411fc153; /* r1p3 */ cpu->isar.id_pfr0 = 0x0131; cpu->isar.id_pfr1 = 0x001; @@ -850,181 +818,153 @@ static void cortex_r5_initfn(Object *obj) cpu->isar.id_isar6 = 0x0; cpu->pmsav7_dregion = 16; cpu->isar.reset_pmcr_el0 = 0x41151800; - define_arm_cp_regs(cpu, cortexr5_cp_reginfo); + define_arm_cp_regs_with_class(cpu, cortexr5_cp_reginfo, NULL); } -static void cortex_r5f_initfn(Object *obj) +static void cortex_r5f_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - - cortex_r5_initfn(obj); + cortex_r5_class_init(cpu); cpu->isar.mvfr0 = 0x10110221; cpu->isar.mvfr1 = 0x00000011; } -static void ti925t_initfn(Object *obj) +static void ti925t_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = 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 = ARM_CPUID_TI925T; cpu->ctr = 0x5109149; cpu->reset_sctlr = 0x00000070; } -static void sa1100_initfn(Object *obj) +static void sa1100_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = 0x4401A11B; cpu->reset_sctlr = 0x00000070; } -static void sa1110_initfn(Object *obj) +static void sa1110_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = 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 = 0x6901B119; cpu->reset_sctlr = 0x00000070; } -static void pxa250_initfn(Object *obj) +static void pxa250_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = 0x69052100; cpu->ctr = 0xd172172; cpu->reset_sctlr = 0x00000078; } -static void pxa255_initfn(Object *obj) +static void pxa255_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = 0x69052d00; cpu->ctr = 0xd172172; cpu->reset_sctlr = 0x00000078; } -static void pxa260_initfn(Object *obj) +static void pxa260_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = 0x69052903; cpu->ctr = 0xd172172; cpu->reset_sctlr = 0x00000078; } -static void pxa261_initfn(Object *obj) +static void pxa261_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = 0x69052d05; cpu->ctr = 0xd172172; cpu->reset_sctlr = 0x00000078; } -static void pxa262_initfn(Object *obj) +static void pxa262_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = 0x69052d06; cpu->ctr = 0xd172172; cpu->reset_sctlr = 0x00000078; } -static void pxa270a0_initfn(Object *obj) +static void pxa270a0_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = 0x69054110; cpu->ctr = 0xd172172; cpu->reset_sctlr = 0x00000078; } -static void pxa270a1_initfn(Object *obj) +static void pxa270a1_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = 0x69054111; cpu->ctr = 0xd172172; cpu->reset_sctlr = 0x00000078; } -static void pxa270b0_initfn(Object *obj) +static void pxa270b0_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = 0x69054112; cpu->ctr = 0xd172172; cpu->reset_sctlr = 0x00000078; } -static void pxa270b1_initfn(Object *obj) +static void pxa270b1_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = 0x69054113; cpu->ctr = 0xd172172; cpu->reset_sctlr = 0x00000078; } -static void pxa270c0_initfn(Object *obj) +static void pxa270c0_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = 0x69054114; cpu->ctr = 0xd172172; cpu->reset_sctlr = 0x00000078; } -static void pxa270c5_initfn(Object *obj) +static void pxa270c5_class_init(ARMCPUClass *cpu) { - ARMCPU *cpu = ARM_CPU(obj); - cpu->dtb_compatible = "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 = 0x69054117; cpu->ctr = 0xd172172; cpu->reset_sctlr = 0x00000078; @@ -1070,19 +1010,17 @@ static void arm_v7m_class_init(ObjectClass *oc, void *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 = 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 = "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 = 0x411fd070; cpu->revidr = 0x00000000; cpu->reset_fpsid = 0x41034070; @@ -1130,55 +1068,55 @@ static void arm_max_initfn(Object *obj) #endif /* !TARGET_AARCH64 */ static const ARMCPUInfo arm_tcg_cpus[] = { - { .name = "arm926", .initfn = arm926_initfn }, - { .name = "arm946", .initfn = arm946_initfn }, - { .name = "arm1026", .initfn = arm1026_initfn }, + { .name = "arm926", .class_init = arm926_class_init }, + { .name = "arm946", .class_init = arm946_class_init }, + { .name = "arm1026", .class_init = 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 = "arm1136-r2", .initfn = arm1136_r2_initfn }, - { .name = "arm1136", .initfn = arm1136_initfn }, - { .name = "arm1176", .initfn = arm1176_initfn }, - { .name = "arm11mpcore", .initfn = arm11mpcore_initfn }, - { .name = "cortex-a7", .initfn = cortex_a7_initfn }, - { .name = "cortex-a8", .initfn = cortex_a8_initfn }, - { .name = "cortex-a9", .initfn = cortex_a9_initfn }, - { .name = "cortex-a15", .initfn = cortex_a15_initfn }, - { .name = "cortex-r5", .initfn = cortex_r5_initfn }, - { .name = "cortex-r5f", .initfn = cortex_r5f_initfn }, - { .name = "ti925t", .initfn = ti925t_initfn }, - { .name = "sa1100", .initfn = sa1100_initfn }, - { .name = "sa1110", .initfn = sa1110_initfn }, - { .name = "pxa250", .initfn = pxa250_initfn }, - { .name = "pxa255", .initfn = pxa255_initfn }, - { .name = "pxa260", .initfn = pxa260_initfn }, - { .name = "pxa261", .initfn = pxa261_initfn }, - { .name = "pxa262", .initfn = pxa262_initfn }, + { .name = "arm1136-r2", .class_init = arm1136_r2_class_init }, + { .name = "arm1136", .class_init = arm1136_class_init }, + { .name = "arm1176", .class_init = arm1176_class_init }, + { .name = "arm11mpcore", .class_init = arm11mpcore_class_init }, + { .name = "cortex-a7", .class_init = cortex_a7_class_init }, + { .name = "cortex-a8", .class_init = cortex_a8_class_init }, + { .name = "cortex-a9", .class_init = cortex_a9_class_init }, + { .name = "cortex-a15", .class_init = cortex_a15_class_init }, + { .name = "cortex-r5", .class_init = cortex_r5_class_init }, + { .name = "cortex-r5f", .class_init = cortex_r5f_class_init }, + { .name = "ti925t", .class_init = ti925t_class_init }, + { .name = "sa1100", .class_init = sa1100_class_init }, + { .name = "sa1110", .class_init = sa1110_class_init }, + { .name = "pxa250", .class_init = pxa250_class_init }, + { .name = "pxa255", .class_init = pxa255_class_init }, + { .name = "pxa260", .class_init = pxa260_class_init }, + { .name = "pxa261", .class_init = pxa261_class_init }, + { .name = "pxa262", .class_init = pxa262_class_init }, /* "pxa270" is an alias for "pxa270-a0" */ - { .name = "pxa270", .initfn = pxa270a0_initfn }, - { .name = "pxa270-a0", .initfn = pxa270a0_initfn }, - { .name = "pxa270-a1", .initfn = pxa270a1_initfn }, - { .name = "pxa270-b0", .initfn = pxa270b0_initfn }, - { .name = "pxa270-b1", .initfn = pxa270b1_initfn }, - { .name = "pxa270-c0", .initfn = pxa270c0_initfn }, - { .name = "pxa270-c5", .initfn = pxa270c5_initfn }, + { .name = "pxa270", .class_init = pxa270a0_class_init }, + { .name = "pxa270-a0", .class_init = pxa270a0_class_init }, + { .name = "pxa270-a1", .class_init = pxa270a1_class_init }, + { .name = "pxa270-b0", .class_init = pxa270b0_class_init }, + { .name = "pxa270-b1", .class_init = pxa270b1_class_init }, + { .name = "pxa270-c0", .class_init = pxa270c0_class_init }, + { .name = "pxa270-c5", .class_init = pxa270c5_class_init }, #ifndef TARGET_AARCH64 - { .name = "max", .initfn = arm_max_initfn }, + { .name = "max", .class_init = arm_max_class_init }, #endif #ifdef CONFIG_USER_ONLY - { .name = "any", .initfn = arm_max_initfn }, + { .name = "any", .class_init = arm_max_class_init }, #endif }; static const ARMCPUInfo arm_v7m_tcg_cpus[] = { - { .name = "cortex-m0", .initfn = cortex_m0_initfn }, - { .name = "cortex-m3", .initfn = cortex_m3_initfn }, - { .name = "cortex-m4", .initfn = cortex_m4_initfn }, - { .name = "cortex-m7", .initfn = cortex_m7_initfn }, - { .name = "cortex-m33", .initfn = cortex_m33_initfn }, - { .name = "cortex-m55", .initfn = cortex_m55_initfn }, + { .name = "cortex-m0", .class_init = cortex_m0_class_init }, + { .name = "cortex-m3", .class_init = cortex_m3_class_init }, + { .name = "cortex-m4", .class_init = cortex_m4_class_init }, + { .name = "cortex-m7", .class_init = cortex_m7_class_init }, + { .name = "cortex-m33", .class_init = cortex_m33_class_init }, + { .name = "cortex-m55", .class_init = cortex_m55_class_init }, }; static const TypeInfo arm_v7m_cpu_type_info = { From patchwork Tue Jan 3 18:16:26 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638745 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1392534pvb; Tue, 3 Jan 2023 10:23:17 -0800 (PST) X-Google-Smtp-Source: AMrXdXvPIEEoPljv7H0kFrzGn61eMHVFztfvb/KRBZP3dnIb2T0t2//XaoGGZv3knCDZkFE2e0I2 X-Received: by 2002:a05:622a:4291:b0:3a5:fba4:96cf with SMTP id cr17-20020a05622a429100b003a5fba496cfmr69071179qtb.9.1672770197214; Tue, 03 Jan 2023 10:23:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770197; cv=none; d=google.com; s=arc-20160816; b=GCZANiC+Z4tqnBXSfs8KBNZcnidLWlJBOAhGmVvy8IMi+EU5Q9F71fz9ngUBJiCE8x wTBeGgS4GWksAgVv2XxhWVT4vZ4MggwdERZT5AAXjXpOolUcfC1whNssOn+hyVNMFJYQ eKiVjKbGltDHhQ8tv+dij0bfU9M2zauop00Hgo2vRv2R9VEzAI2LBIAb6/e2QbXc2vxV FxFO3oVkN3qE3Ph3vXbMkV1vqm5rRh8xznbo80+ozLP+yy1m88WFFHocUvj2jv1XMhnI Dh65etPcPFUwU2AFc5wjuzPkPJTAt6gVu9rY0gx9KZ4WJCzUMYsA8lGqaPGi6jSR9Got 9lYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=WOgkxoomlodohQOeAEcc5A6oSk0mtn0fP77laaeYcB0=; b=cxGugGDzWQjqKr8HynIxhqd9N+sS/j3ZxUYDtOzwr5HrXtfwaCdTeYiL7OXUJpFrRl TPaXH3hr2bdcls7+eA4JtK8cM11utSFEEchVtC9qoTpyfsO9DdZcIotsNK46iYp+f+bO v/pD5Uh+AsoVCluUwrXMXhjiYcnC3Fsue+5kUK6hqbKgONTxCxn8Du53cbABXolb/odg n2y2c3cTCGy4qZS9HzRMzs+HPi8nly6Xj8NEYlLpxBrKZI8r0Q5HRbC0/TLewMd5WzVO 9vrDTguWczONmcgDNOSUw/PWp8yiJ2zp/eYje5Qmt8L6S/Sm9wJzJSCscphbJKD4BbMp 3M3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="tzz/tsxN"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id f3-20020a05622a114300b003a603561e0esi16643416qty.485.2023.01.03.10.23.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:23:17 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="tzz/tsxN"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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) -/** - * 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 group, uint64_t attr, int dev_fd, uint64_t addr_ormask); -/** - * 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_STATE. - */ -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); -/** - * 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); -/** - * 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); -/** - * 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); -/** - * 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 state. - */ -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); void kvm_arm_pmu_set_irq(CPUState *cs, int irq); @@ -471,43 +318,6 @@ static inline const char *gicv3_class_name(void) } } -/** - * 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" const KVMCapabilityInfo kvm_arch_required_capabilities[] = { @@ -40,9 +44,30 @@ static bool cap_has_mp_state; static bool cap_has_inject_serror_esr; static bool cap_has_inject_ext_dabt; +/** + * 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; -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 = 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); } -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); } -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 = 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) } } -void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) -{ - CPUARMState *env = &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 = QEMU_KVM_ARM_TARGET_NONE; - cpu->host_cpu_probe_failed = true; - return; - } - } - - cpu->kvm_target = arm_host_cpu_features.target; - cpu->dtb_compatible = arm_host_cpu_features.dtb_compatible; - cpu->isar = arm_host_cpu_features.isar; - env->features = 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, uint64_t regidx) return &cpu->cpreg_values[res - cpu->cpreg_indexes]; } -/* 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; } +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[] = { + { 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_STATE. + */ +static int kvm_arm_cpreg_level(uint64_t regidx) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(non_runtime_cpregs); i++) { + const CPRegStateLevel *l = &non_runtime_cpregs[i]; + if (l->regidx == regidx) { + return l->level; + } + } + + return KVM_PUT_RUNTIME_STATE; +} + bool write_list_to_kvmstate(ARMCPU *cpu, int level) { CPUState *cs = CPU(cpu); @@ -634,10 +719,15 @@ void kvm_arm_reset_vcpu(ARMCPU *cpu) write_list_to_cpustate(cpu); } -/* - * 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 = { @@ -655,10 +745,15 @@ int kvm_arm_sync_mpstate_to_kvm(ARMCPU *cpu) return 0; } -/* - * 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; } -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 = ARM_CPU(cs); struct kvm_one_reg reg = { @@ -697,7 +798,13 @@ void kvm_arm_get_virtual_time(CPUState *cs) cpu->kvm_vtime_dirty = true; } -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 state. + */ +static void kvm_arm_put_virtual_time(CPUState *cs) { ARMCPU *cpu = ARM_CPU(cs); struct kvm_one_reg reg = { @@ -719,7 +826,15 @@ void kvm_arm_put_virtual_time(CPUState *cs) cpu->kvm_vtime_dirty = false; } -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 = &cpu->env; struct kvm_vcpu_events events; @@ -748,7 +863,15 @@ int kvm_put_vcpu_events(ARMCPU *cpu) return ret; } -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 = &cpu->env; struct kvm_vcpu_events events; @@ -772,88 +895,7 @@ int kvm_get_vcpu_events(ARMCPU *cpu) return 0; } -void kvm_arch_pre_run(CPUState *cs, struct kvm_run *run) -{ - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; - - if (unlikely(env->ext_dabt_raised)) { - /* - * Verifying that the ext DABT has been properly injected, - * otherwise risking indefinitely re-running the faulting instruction - * 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 = 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 = ARM_CPU(cs); - - /* Synchronize our shadowed in-kernel device irq lines with the kvm ones */ - if (run->s.regs.device_irq_level != cpu->device_irq_level) { - switched_level = 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 &= ~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 &= ~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 &= ~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 = 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 state) { CPUState *cs = opaque; ARMCPU *cpu = ARM_CPU(cs); @@ -910,29 +952,6 @@ static int kvm_arm_handle_dabt_nisv(CPUState *cs, uint64_t esr_iss, return -1; } -int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) -{ - int ret = 0; - - switch (run->exit_reason) { - case KVM_EXIT_DEBUG: - if (kvm_arm_handle_debug(cs, &run->debug.arch)) { - ret = EXCP_DEBUG; - } /* otherwise return to guest */ - break; - case KVM_EXIT_ARM_NISV: - /* External DABT with no valid iss to decode */ - ret = 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; } -void kvm_arch_update_guest_debug(CPUState *cs, struct kvm_guest_debug *dbg) -{ - if (kvm_sw_breakpoints_active(cs)) { - dbg->control |= KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_SW_BP; - } - if (kvm_arm_hw_debug_active(cs)) { - dbg->control |= 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 = kvm_check_extension(cs->kvm_state, + KVM_CAP_SET_GUEST_DEBUG); + + max_hw_wps = kvm_check_extension(cs->kvm_state, KVM_CAP_GUEST_DEBUG_HW_WPS); + hw_watchpoints = g_array_sized_new(true, true, + sizeof(HWWatchpoint), max_hw_wps); + + max_hw_bps = kvm_check_extension(cs->kvm_state, KVM_CAP_GUEST_DEBUG_HW_BPS); + hw_breakpoints = 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 = unlinked address match) + * LBN: Linked BP number (0 = 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 = { + .bcr = 0x1, /* BCR E=1, enable */ + .bvr = sextract64(addr, 0, 53) + }; + + if (cur_hw_bps >= max_hw_bps) { + return -ENOBUFS; + } + + brk.bcr = deposit32(brk.bcr, 1, 2, 0x3); /* PMC = 11 */ + brk.bcr = deposit32(brk.bcr, 5, 4, 0xf); /* BAS = 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 = 0; i < hw_breakpoints->len; i++) { + HWBreakpoint *brk = get_hw_bp(i); + if (brk->bvr == 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=none,01/10=res,11=3 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=0, BAS=bit per byte in question. For larger regions (^2) you + * need to ensure you mask the address as required and set BAS=0xff + */ + +static int insert_hw_watchpoint(target_ulong addr, + target_ulong len, int type) +{ + HWWatchpoint wp = { + .wcr = R_DBGWCR_E_MASK, /* E=1, enable */ + .wvr = addr & (~0x7ULL), + .details = { .vaddr = addr, .len = len } + }; + + if (cur_hw_wps >= max_hw_wps) { + return -ENOBUFS; + } + + /* + * HMC=0 SSC=0 PAC=3 will hit EL0 or EL1, any security state, + * valid whether EL3 is implemented or not + */ + wp.wcr = FIELD_DP64(wp.wcr, DBGWCR, PAC, 3); + + switch (type) { + case GDB_WATCHPOINT_READ: + wp.wcr = FIELD_DP64(wp.wcr, DBGWCR, LSC, 1); + wp.details.flags = BP_MEM_READ; + break; + case GDB_WATCHPOINT_WRITE: + wp.wcr = FIELD_DP64(wp.wcr, DBGWCR, LSC, 2); + wp.details.flags = BP_MEM_WRITE; + break; + case GDB_WATCHPOINT_ACCESS: + wp.wcr = FIELD_DP64(wp.wcr, DBGWCR, LSC, 3); + wp.details.flags = BP_MEM_ACCESS; + break; + default: + g_assert_not_reached(); + break; + } + if (len <= 8) { + /* we align the address and set the bits in BAS */ + int off = addr & 0x7; + int bas = (1 << len) - 1; + + wp.wcr = 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 = ctz64(len); + + wp.wvr &= ~((1 << bits) - 1); + wp.wcr = FIELD_DP64(wp.wcr, DBGWCR, MASK, bits); + wp.wcr = 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 = get_hw_wp(i); + uint64_t addr_top, addr_bottom = wp->wvr; + int bas = extract32(wp->wcr, 5, 8); + int mask = extract32(wp->wcr, 24, 4); + + if (mask) { + addr_top = addr_bottom + (1 << mask); + } else { + /* BAS must be contiguous but can offset against the base + * address in DBGWVR */ + addr_bottom = addr_bottom + ctz32(bas); + addr_top = addr_bottom + clo32(bas); + } + + if (addr >= addr_bottom && addr <= 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 = 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 = 0; i < max_hw_wps; i++) { + HWWatchpoint *wp = get_hw_wp(i); + ptr->dbg_wcr[i] = wp->wcr; + ptr->dbg_wvr[i] = wp->wvr; + } + for (i = 0; i < max_hw_bps; i++) { + HWBreakpoint *bp = get_hw_bp(i); + ptr->dbg_bcr[i] = bp->bcr; + ptr->dbg_bvr[i] = 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 = 0; i < cur_hw_bps; i++) { + HWBreakpoint *bp = get_hw_bp(i); + if (bp->bvr == pc) { + return true; + } + } + return false; +} + +static CPUWatchpoint *find_hw_watchpoint(CPUState *cpu, target_ulong addr) +{ + int i; + + for (i = 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 = kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, attr); + if (err != 0) { + error_report("%s: KVM_HAS_DEVICE_ATTR: %s", name, strerror(-err)); + return false; + } + + err = kvm_vcpu_ioctl(cs, KVM_SET_DEVICE_ATTR, attr); + if (err != 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 = { + .group = KVM_ARM_VCPU_PMU_V3_CTRL, + .attr = 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 = { + .group = KVM_ARM_VCPU_PMU_V3_CTRL, + .addr = (intptr_t)&irq, + .attr = 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 = { + .group = KVM_ARM_VCPU_PVTIME_CTRL, + .attr = KVM_ARM_VCPU_PVTIME_IPA, + .addr = (uint64_t)&ipa, + }; + + if (ARM_CPU(cs)->kvm_steal_time == 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 = { .id = id, .addr = (uintptr_t)&ret }; + int err; + + assert((id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U64); + err = ioctl(fd, KVM_GET_ONE_REG, &idreg); + if (err < 0) { + return -1; + } + *pret = ret; + return 0; +} + +static int read_sys_reg64(int fd, uint64_t *pret, uint64_t id) +{ + struct kvm_one_reg idreg = { .id = id, .addr = (uintptr_t)pret }; + + assert((id & KVM_REG_SIZE_MASK) == 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 = false; + uint64_t features = 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[] = { + KVM_ARM_TARGET_AEM_V8, + KVM_ARM_TARGET_FOUNDATION_V8, + KVM_ARM_TARGET_CORTEX_A57, + QEMU_KVM_ARM_TARGET_NONE + }; + /* + * target = -1 informs kvm_arm_create_scratch_host_vcpu() + * to use the preferred target + */ + struct kvm_vcpu_init init = { .target = -1, }; + + /* + * Ask for SVE if supported, so that we can query ID_AA64ZFR0, + * which is otherwise RAZ. + */ + sve_supported = kvm_arm_sve_supported(); + if (sve_supported) { + init.features[0] |= 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] |= (1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS | + 1 << KVM_ARM_VCPU_PTRAUTH_GENERIC); + } + + if (kvm_arm_pmu_supported()) { + init.features[0] |= 1 << KVM_ARM_VCPU_PMU_V3; + pmu_supported = true; + } + + if (!kvm_arm_create_scratch_host_vcpu(cpus_to_try, fdarray, &init)) { + return false; + } + + ahcf->target = init.target; + ahcf->dtb_compatible = "arm,arm-v8"; + + err = 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 minimal + * 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 = 0x00000011; /* EL1&0, AArch64 only */ + err = 0; + } else { + err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64pfr1, + ARM64_SYS_REG(3, 0, 0, 4, 1)); + err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64smfr0, + ARM64_SYS_REG(3, 0, 0, 4, 5)); + err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64dfr0, + ARM64_SYS_REG(3, 0, 0, 5, 0)); + err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64dfr1, + ARM64_SYS_REG(3, 0, 0, 5, 1)); + err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64isar0, + ARM64_SYS_REG(3, 0, 0, 6, 0)); + err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64isar1, + ARM64_SYS_REG(3, 0, 0, 6, 1)); + err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr0, + ARM64_SYS_REG(3, 0, 0, 7, 0)); + err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr1, + ARM64_SYS_REG(3, 0, 0, 7, 1)); + err |= 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 |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr0, + ARM64_SYS_REG(3, 0, 0, 1, 0)); + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr1, + ARM64_SYS_REG(3, 0, 0, 1, 1)); + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_dfr0, + ARM64_SYS_REG(3, 0, 0, 1, 2)); + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr0, + ARM64_SYS_REG(3, 0, 0, 1, 4)); + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr1, + ARM64_SYS_REG(3, 0, 0, 1, 5)); + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr2, + ARM64_SYS_REG(3, 0, 0, 1, 6)); + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr3, + ARM64_SYS_REG(3, 0, 0, 1, 7)); + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar0, + ARM64_SYS_REG(3, 0, 0, 2, 0)); + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar1, + ARM64_SYS_REG(3, 0, 0, 2, 1)); + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar2, + ARM64_SYS_REG(3, 0, 0, 2, 2)); + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar3, + ARM64_SYS_REG(3, 0, 0, 2, 3)); + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar4, + ARM64_SYS_REG(3, 0, 0, 2, 4)); + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar5, + ARM64_SYS_REG(3, 0, 0, 2, 5)); + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr4, + ARM64_SYS_REG(3, 0, 0, 2, 6)); + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar6, + ARM64_SYS_REG(3, 0, 0, 2, 7)); + + err |= read_sys_reg32(fdarray[2], &ahcf->isar.mvfr0, + ARM64_SYS_REG(3, 0, 0, 3, 0)); + err |= read_sys_reg32(fdarray[2], &ahcf->isar.mvfr1, + ARM64_SYS_REG(3, 0, 0, 3, 1)); + err |= read_sys_reg32(fdarray[2], &ahcf->isar.mvfr2, + ARM64_SYS_REG(3, 0, 0, 3, 2)); + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr2, + ARM64_SYS_REG(3, 0, 0, 3, 4)); + err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_dfr1, + ARM64_SYS_REG(3, 0, 0, 3, 5)); + err |= 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) >= 2) { + int wrps = FIELD_EX64(ahcf->isar.id_aa64dfr0, ID_AA64DFR0, WRPS); + int brps = FIELD_EX64(ahcf->isar.id_aa64dfr0, ID_AA64DFR0, BRPS); + int ctx_cmps = + FIELD_EX64(ahcf->isar.id_aa64dfr0, ID_AA64DFR0, CTX_CMPS); + int version = 6; /* ARMv8 debug architecture */ + bool has_el3 = + !!FIELD_EX32(ahcf->isar.id_aa64pfr0, ID_AA64PFR0, EL3); + uint32_t dbgdidr = 0; + + dbgdidr = FIELD_DP32(dbgdidr, DBGDIDR, WRPS, wrps); + dbgdidr = FIELD_DP32(dbgdidr, DBGDIDR, BRPS, brps); + dbgdidr = FIELD_DP32(dbgdidr, DBGDIDR, CTX_CMPS, ctx_cmps); + dbgdidr = FIELD_DP32(dbgdidr, DBGDIDR, VERSION, version); + dbgdidr = FIELD_DP32(dbgdidr, DBGDIDR, NSUHD_IMP, has_el3); + dbgdidr = FIELD_DP32(dbgdidr, DBGDIDR, SE_IMP, has_el3); + dbgdidr |= (1 << 15); /* RES1 bit */ + ahcf->isar.dbgdidr = dbgdidr; + } + + if (pmu_supported) { + /* PMCR_EL0 is only accessible if the vCPU has feature PMU_V3 */ + err |= 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 73433762fcae + * and f81cb2c3ad41 which have a bug where the kernel doesn't + * expose SYS_ID_AA64ZFR0_EL1 via the ONE_REG API unless the VM 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 |= 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 |= 1ULL << ARM_FEATURE_V8; + features |= 1ULL << ARM_FEATURE_NEON; + features |= 1ULL << ARM_FEATURE_AARCH64; + features |= 1ULL << ARM_FEATURE_PMU; + features |= 1ULL << ARM_FEATURE_GENERIC_TIMER; + + ahcf->features = features; + + return true; +} + +void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) +{ + CPUARMState *env = &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 = QEMU_KVM_ARM_TARGET_NONE; + cpu->host_cpu_probe_failed = true; + return; + } + } + + cpu->kvm_target = arm_host_cpu_features.target; + cpu->dtb_compatible = arm_host_cpu_features.dtb_compatible; + cpu->isar = arm_host_cpu_features.isar; + env->features = 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 = kvm_arm_steal_time_supported(); + + if (cpu->kvm_steal_time == ON_OFF_AUTO_AUTO) { + if (!has_steal_time || !arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { + cpu->kvm_steal_time = ON_OFF_AUTO_OFF; + } else { + cpu->kvm_steal_time = ON_OFF_AUTO_ON; + } + } else if (cpu->kvm_steal_time == 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 != 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 = 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 = { + .target = -1, + .features[0] = (1 << KVM_ARM_VCPU_SVE), + }; + struct kvm_one_reg reg = { + .id = KVM_REG_ARM64_SVE_VLS, + .addr = (uint64_t)&vls[0], + }; + int fdarray[3], ret; + + probed = true; + + if (!kvm_arm_create_scratch_host_vcpu(NULL, fdarray, &init)) { + error_report("failed to create scratch VCPU with SVE enabled"); + abort(); + } + ret = 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 = KVM_ARM64_SVE_VLS_WORDS - 1; i >= 0; --i) { + if (vls[i]) { + vq = 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] &= MAKE_64BIT_MASK(0, ARM_MAX_VQ); + } + } + + return vls[0]; +} + +static int kvm_arm_sve_set_vls(CPUState *cs) +{ + ARMCPU *cpu = ARM_CPU(cs); + uint64_t vls[KVM_ARM64_SVE_VLS_WORDS] = { cpu->sve_vq.map }; + struct kvm_one_reg reg = { + .id = KVM_REG_ARM64_SVE_VLS, + .addr = (uint64_t)&vls[0], + }; + + assert(cpu->sve_max_vq <= 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 = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + uint64_t psciver; + + if (cpu->kvm_target == 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] |= 1 << KVM_ARM_VCPU_POWER_OFF; + } + if (kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PSCI_0_2)) { + cpu->psci_version = QEMU_PSCI_VERSION_0_2; + cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_PSCI_0_2; + } + if (!arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { + cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_EL1_32BIT; + } + if (!kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PMU_V3)) { + cpu->has_pmu = false; + } + if (cpu->has_pmu) { + cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_PMU_V3; + } else { + env->features &= ~(1ULL << ARM_FEATURE_PMU); + } + if (cpu_isar_feature(aa64_sve, cpu)) { + assert(kvm_arm_sve_supported()); + cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_SVE; + } + if (cpu_isar_feature(aa64_pauth, cpu)) { + cpu->kvm_init_features[0] |= (1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS | + 1 << KVM_ARM_VCPU_PTRAUTH_GENERIC); + } + + /* Do KVM_ARM_VCPU_INIT ioctl */ + ret = kvm_arm_vcpu_init(cs); + if (ret) { + return ret; + } + + if (cpu_isar_feature(aa64_sve, cpu)) { + ret = kvm_arm_sve_set_vls(cs); + if (ret) { + return ret; + } + ret = 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 = 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 = 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 = ARM_CPU(c); + CPUARMState *env = &cpu->env; + uint32_t esr; + bool same_el; + + c->exception_index = EXCP_DATA_ABORT; + env->exception.target_el = 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 = arm_current_el(env) == env->exception.target_el; + esr = syn_data_abort_no_iss(same_el, 1, 0, 0, 0, 0, 0x10); + + env->exception.syndrome = 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 = &ARM_CPU(cs)->env; + struct kvm_one_reg reg; + int i, ret; + + for (i = 0; i < 32; i++) { + uint64_t *q = aa64_vfp_qreg(env, i); +#if HOST_BIG_ENDIAN + uint64_t fp_val[2] = { q[1], q[0] }; + reg.addr = (uintptr_t)fp_val; +#else + reg.addr = (uintptr_t)q; +#endif + reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); + ret = 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 than + * one slice for quite some time. + */ +static int kvm_arch_put_sve(CPUState *cs) +{ + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + uint64_t tmp[ARM_MAX_VQ * 2]; + uint64_t *r; + struct kvm_one_reg reg; + int n, ret; + + for (n = 0; n < KVM_ARM64_SVE_NUM_ZREGS; ++n) { + r = sve_bswap64(tmp, &env->vfp.zregs[n].d[0], cpu->sve_max_vq * 2); + reg.addr = (uintptr_t)r; + reg.id = KVM_REG_ARM64_SVE_ZREG(n, 0); + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + } + + for (n = 0; n < KVM_ARM64_SVE_NUM_PREGS; ++n) { + r = sve_bswap64(tmp, r = &env->vfp.pregs[n].p[0], + DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); + reg.addr = (uintptr_t)r; + reg.id = KVM_REG_ARM64_SVE_PREG(n, 0); + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + } + + r = sve_bswap64(tmp, &env->vfp.pregs[FFR_PRED_NUM].p[0], + DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); + reg.addr = (uintptr_t)r; + reg.id = KVM_REG_ARM64_SVE_FFR(0); + ret = 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 = ARM_CPU(cs); + CPUARMState *env = &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 = 0; i < 31; i++) { + reg.id = AARCH64_CORE_REG(regs.regs[i]); + reg.addr = (uintptr_t) &env->xregs[i]; + ret = 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 = AARCH64_CORE_REG(regs.sp); + reg.addr = (uintptr_t) &env->sp_el[0]; + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + + reg.id = AARCH64_CORE_REG(sp_el1); + reg.addr = (uintptr_t) &env->sp_el[1]; + ret = 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 = pstate_read(env); + } else { + val = cpsr_read(env); + } + reg.id = AARCH64_CORE_REG(regs.pstate); + reg.addr = (uintptr_t) &val; + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + + reg.id = AARCH64_CORE_REG(regs.pc); + reg.addr = (uintptr_t) &env->pc; + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + + reg.id = AARCH64_CORE_REG(elr_el1); + reg.addr = (uintptr_t) &env->elr_el[1]; + ret = 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 = arm_current_el(env); + if (el > 0 && !is_a64(env)) { + i = bank_number(env->uncached_cpsr & CPSR_M); + env->banked_spsr[i] = env->spsr; + } + + /* KVM 0-4 map to QEMU banks 1-5 */ + for (i = 0; i < KVM_NR_SPSR; i++) { + reg.id = AARCH64_CORE_REG(spsr[i]); + reg.addr = (uintptr_t) &env->banked_spsr[i + 1]; + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + } + + if (cpu_isar_feature(aa64_sve, cpu)) { + ret = kvm_arch_put_sve(cs); + } else { + ret = kvm_arch_put_fpsimd(cs); + } + if (ret) { + return ret; + } + + reg.addr = (uintptr_t)(&fpr); + fpr = vfp_get_fpsr(env); + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); + ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); + if (ret) { + return ret; + } + + reg.addr = (uintptr_t)(&fpr); + fpr = vfp_get_fpcr(env); + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); + ret = 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 = 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 = &ARM_CPU(cs)->env; + struct kvm_one_reg reg; + int i, ret; + + for (i = 0; i < 32; i++) { + uint64_t *q = aa64_vfp_qreg(env, i); + reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); + reg.addr = (uintptr_t)q; + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } else { +#if HOST_BIG_ENDIAN + uint64_t t; + t = q[0], q[0] = q[1], q[1] = 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 than + * one slice for quite some time. + */ +static int kvm_arch_get_sve(CPUState *cs) +{ + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + struct kvm_one_reg reg; + uint64_t *r; + int n, ret; + + for (n = 0; n < KVM_ARM64_SVE_NUM_ZREGS; ++n) { + r = &env->vfp.zregs[n].d[0]; + reg.addr = (uintptr_t)r; + reg.id = KVM_REG_ARM64_SVE_ZREG(n, 0); + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + sve_bswap64(r, r, cpu->sve_max_vq * 2); + } + + for (n = 0; n < KVM_ARM64_SVE_NUM_PREGS; ++n) { + r = &env->vfp.pregs[n].p[0]; + reg.addr = (uintptr_t)r; + reg.id = KVM_REG_ARM64_SVE_PREG(n, 0); + ret = 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 = &env->vfp.pregs[FFR_PRED_NUM].p[0]; + reg.addr = (uintptr_t)r; + reg.id = KVM_REG_ARM64_SVE_FFR(0); + ret = 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 = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + + for (i = 0; i < 31; i++) { + reg.id = AARCH64_CORE_REG(regs.regs[i]); + reg.addr = (uintptr_t) &env->xregs[i]; + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + } + + reg.id = AARCH64_CORE_REG(regs.sp); + reg.addr = (uintptr_t) &env->sp_el[0]; + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + + reg.id = AARCH64_CORE_REG(sp_el1); + reg.addr = (uintptr_t) &env->sp_el[1]; + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + + reg.id = AARCH64_CORE_REG(regs.pstate); + reg.addr = (uintptr_t) &val; + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + + env->aarch64 = ((val & PSTATE_nRW) == 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 = AARCH64_CORE_REG(regs.pc); + reg.addr = (uintptr_t) &env->pc; + ret = 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 with 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 = AARCH64_CORE_REG(elr_el1); + reg.addr = (uintptr_t) &env->elr_el[1]; + ret = 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 = 0; i < KVM_NR_SPSR; i++) { + reg.id = AARCH64_CORE_REG(spsr[i]); + reg.addr = (uintptr_t) &env->banked_spsr[i + 1]; + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + } + + el = arm_current_el(env); + if (el > 0 && !is_a64(env)) { + i = bank_number(env->uncached_cpsr & CPSR_M); + env->spsr = env->banked_spsr[i]; + } + + if (cpu_isar_feature(aa64_sve, cpu)) { + ret = kvm_arch_get_sve(cs); + } else { + ret = kvm_arch_get_fpsimd(cs); + } + if (ret) { + return ret; + } + + reg.addr = (uintptr_t)(&fpr); + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + vfp_set_fpsr(env, fpr); + + reg.addr = (uintptr_t)(&fpr); + reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); + ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); + if (ret) { + return ret; + } + vfp_set_fpcr(env, fpr); + + ret = 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 == BUS_MCEERR_AR || code == BUS_MCEERR_AO); + + if (acpi_ghes_present() && addr) { + ram_addr = qemu_ram_addr_from_host(addr); + if (ram_addr != 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 == 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 == BUS_MCEERR_AO) { + error_report("Hardware memory error at addr %p for memory used by " + "QEMU itself instead of guest system!", addr); + } + } + + if (code == BUS_MCEERR_AR) { + error_report("Hardware memory error!"); + exit(1); + } +} + +/* C6.6.29 BRK instruction */ +static const uint32_t brk_insn = 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 != 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 = syn_get_ec(debug_exit->hsr); + ARMCPU *cpu = ARM_CPU(cs); + CPUARMState *env = &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 unsupported" + " (%"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 = find_hw_watchpoint(cs, debug_exit->far); + if (wp) { + cs->watchpoint_hit = 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 = EXCP_BKPT; + env->exception.syndrome = debug_exit->hsr; + env->exception.vaddress = debug_exit->far; + env->exception.target_el = 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 == 0 + * FS[4] - DFSR[10] + * FS[3:0] - DFSR[3:0] + * TTBCR.EAE == 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 = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + int aarch64_mode = arm_feature(env, ARM_FEATURE_AARCH64); + int lpae = 0; + + if (!aarch64_mode) { + uint64_t ttbcr; + + if (!kvm_get_one_reg(cs, ARM64_REG_TCR_EL1, &ttbcr)) { + lpae = 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) == + ESR_DFSC_EXTABT(aarch64_mode, lpae)); + } + return false; +} + +int kvm_arch_handle_exit(CPUState *cs, struct kvm_run *run) +{ + int ret = 0; + + switch (run->exit_reason) { + case KVM_EXIT_DEBUG: + if (kvm_arm_handle_debug(cs, &run->debug.arch)) { + ret = EXCP_DEBUG; + } /* otherwise return to guest */ + break; + case KVM_EXIT_ARM_NISV: + /* External DABT with no valid iss to decode */ + ret = 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 |= KVM_GUESTDBG_ENABLE | KVM_GUESTDBG_USE_SW_BP; + } + if (kvm_arm_hw_debug_active(cs)) { + dbg->control |= 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 = ARM_CPU(cs); + CPUARMState *env = &cpu->env; + + if (unlikely(env->ext_dabt_raised)) { + /* + * Verifying that the ext DABT has been properly injected, + * otherwise risking indefinitely re-running the faulting instruction + * 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 = 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 = ARM_CPU(cs); + + /* Synchronize our shadowed in-kernel device irq lines with the kvm ones */ + if (run->s.regs.device_irq_level != cpu->device_irq_level) { + switched_level = 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 &= ~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 &= ~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 &= ~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 = 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ée 2014, Linaro - * - * This work is licensed under the terms of the GNU GPL, version 2 or later. - * 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 = kvm_check_extension(cs->kvm_state, - KVM_CAP_SET_GUEST_DEBUG); - - max_hw_wps = kvm_check_extension(cs->kvm_state, KVM_CAP_GUEST_DEBUG_HW_WPS); - hw_watchpoints = g_array_sized_new(true, true, - sizeof(HWWatchpoint), max_hw_wps); - - max_hw_bps = kvm_check_extension(cs->kvm_state, KVM_CAP_GUEST_DEBUG_HW_BPS); - hw_breakpoints = 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 = unlinked address match) - * LBN: Linked BP number (0 = 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 = { - .bcr = 0x1, /* BCR E=1, enable */ - .bvr = sextract64(addr, 0, 53) - }; - - if (cur_hw_bps >= max_hw_bps) { - return -ENOBUFS; - } - - brk.bcr = deposit32(brk.bcr, 1, 2, 0x3); /* PMC = 11 */ - brk.bcr = deposit32(brk.bcr, 5, 4, 0xf); /* BAS = 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 = 0; i < hw_breakpoints->len; i++) { - HWBreakpoint *brk = get_hw_bp(i); - if (brk->bvr == 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=none,01/10=res,11=3 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=0, BAS=bit per byte in question. For larger regions (^2) you - * need to ensure you mask the address as required and set BAS=0xff - */ - -static int insert_hw_watchpoint(target_ulong addr, - target_ulong len, int type) -{ - HWWatchpoint wp = { - .wcr = R_DBGWCR_E_MASK, /* E=1, enable */ - .wvr = addr & (~0x7ULL), - .details = { .vaddr = addr, .len = len } - }; - - if (cur_hw_wps >= max_hw_wps) { - return -ENOBUFS; - } - - /* - * HMC=0 SSC=0 PAC=3 will hit EL0 or EL1, any security state, - * valid whether EL3 is implemented or not - */ - wp.wcr = FIELD_DP64(wp.wcr, DBGWCR, PAC, 3); - - switch (type) { - case GDB_WATCHPOINT_READ: - wp.wcr = FIELD_DP64(wp.wcr, DBGWCR, LSC, 1); - wp.details.flags = BP_MEM_READ; - break; - case GDB_WATCHPOINT_WRITE: - wp.wcr = FIELD_DP64(wp.wcr, DBGWCR, LSC, 2); - wp.details.flags = BP_MEM_WRITE; - break; - case GDB_WATCHPOINT_ACCESS: - wp.wcr = FIELD_DP64(wp.wcr, DBGWCR, LSC, 3); - wp.details.flags = BP_MEM_ACCESS; - break; - default: - g_assert_not_reached(); - break; - } - if (len <= 8) { - /* we align the address and set the bits in BAS */ - int off = addr & 0x7; - int bas = (1 << len) - 1; - - wp.wcr = 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 = ctz64(len); - - wp.wvr &= ~((1 << bits) - 1); - wp.wcr = FIELD_DP64(wp.wcr, DBGWCR, MASK, bits); - wp.wcr = 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 = get_hw_wp(i); - uint64_t addr_top, addr_bottom = wp->wvr; - int bas = extract32(wp->wcr, 5, 8); - int mask = extract32(wp->wcr, 24, 4); - - if (mask) { - addr_top = addr_bottom + (1 << mask); - } else { - /* BAS must be contiguous but can offset against the base - * address in DBGWVR */ - addr_bottom = addr_bottom + ctz32(bas); - addr_top = addr_bottom + clo32(bas); - } - - if (addr >= addr_bottom && addr <= 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 = 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 = 0; i < max_hw_wps; i++) { - HWWatchpoint *wp = get_hw_wp(i); - ptr->dbg_wcr[i] = wp->wcr; - ptr->dbg_wvr[i] = wp->wvr; - } - for (i = 0; i < max_hw_bps; i++) { - HWBreakpoint *bp = get_hw_bp(i); - ptr->dbg_bcr[i] = bp->bcr; - ptr->dbg_bvr[i] = 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 = 0; i < cur_hw_bps; i++) { - HWBreakpoint *bp = get_hw_bp(i); - if (bp->bvr == pc) { - return true; - } - } - return false; -} - -static CPUWatchpoint *find_hw_watchpoint(CPUState *cpu, target_ulong addr) -{ - int i; - - for (i = 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 = kvm_vcpu_ioctl(cs, KVM_HAS_DEVICE_ATTR, attr); - if (err != 0) { - error_report("%s: KVM_HAS_DEVICE_ATTR: %s", name, strerror(-err)); - return false; - } - - err = kvm_vcpu_ioctl(cs, KVM_SET_DEVICE_ATTR, attr); - if (err != 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 = { - .group = KVM_ARM_VCPU_PMU_V3_CTRL, - .attr = 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 = { - .group = KVM_ARM_VCPU_PMU_V3_CTRL, - .addr = (intptr_t)&irq, - .attr = 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 = { - .group = KVM_ARM_VCPU_PVTIME_CTRL, - .attr = KVM_ARM_VCPU_PVTIME_IPA, - .addr = (uint64_t)&ipa, - }; - - if (ARM_CPU(cs)->kvm_steal_time == 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 = { .id = id, .addr = (uintptr_t)&ret }; - int err; - - assert((id & KVM_REG_SIZE_MASK) == KVM_REG_SIZE_U64); - err = ioctl(fd, KVM_GET_ONE_REG, &idreg); - if (err < 0) { - return -1; - } - *pret = ret; - return 0; -} - -static int read_sys_reg64(int fd, uint64_t *pret, uint64_t id) -{ - struct kvm_one_reg idreg = { .id = id, .addr = (uintptr_t)pret }; - - assert((id & KVM_REG_SIZE_MASK) == 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 = false; - uint64_t features = 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[] = { - KVM_ARM_TARGET_AEM_V8, - KVM_ARM_TARGET_FOUNDATION_V8, - KVM_ARM_TARGET_CORTEX_A57, - QEMU_KVM_ARM_TARGET_NONE - }; - /* - * target = -1 informs kvm_arm_create_scratch_host_vcpu() - * to use the preferred target - */ - struct kvm_vcpu_init init = { .target = -1, }; - - /* - * Ask for SVE if supported, so that we can query ID_AA64ZFR0, - * which is otherwise RAZ. - */ - sve_supported = kvm_arm_sve_supported(); - if (sve_supported) { - init.features[0] |= 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] |= (1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS | - 1 << KVM_ARM_VCPU_PTRAUTH_GENERIC); - } - - if (kvm_arm_pmu_supported()) { - init.features[0] |= 1 << KVM_ARM_VCPU_PMU_V3; - pmu_supported = true; - } - - if (!kvm_arm_create_scratch_host_vcpu(cpus_to_try, fdarray, &init)) { - return false; - } - - ahcf->target = init.target; - ahcf->dtb_compatible = "arm,arm-v8"; - - err = 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 minimal - * 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 = 0x00000011; /* EL1&0, AArch64 only */ - err = 0; - } else { - err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64pfr1, - ARM64_SYS_REG(3, 0, 0, 4, 1)); - err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64smfr0, - ARM64_SYS_REG(3, 0, 0, 4, 5)); - err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64dfr0, - ARM64_SYS_REG(3, 0, 0, 5, 0)); - err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64dfr1, - ARM64_SYS_REG(3, 0, 0, 5, 1)); - err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64isar0, - ARM64_SYS_REG(3, 0, 0, 6, 0)); - err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64isar1, - ARM64_SYS_REG(3, 0, 0, 6, 1)); - err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr0, - ARM64_SYS_REG(3, 0, 0, 7, 0)); - err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr1, - ARM64_SYS_REG(3, 0, 0, 7, 1)); - err |= 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 |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr0, - ARM64_SYS_REG(3, 0, 0, 1, 0)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr1, - ARM64_SYS_REG(3, 0, 0, 1, 1)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_dfr0, - ARM64_SYS_REG(3, 0, 0, 1, 2)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr0, - ARM64_SYS_REG(3, 0, 0, 1, 4)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr1, - ARM64_SYS_REG(3, 0, 0, 1, 5)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr2, - ARM64_SYS_REG(3, 0, 0, 1, 6)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr3, - ARM64_SYS_REG(3, 0, 0, 1, 7)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar0, - ARM64_SYS_REG(3, 0, 0, 2, 0)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar1, - ARM64_SYS_REG(3, 0, 0, 2, 1)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar2, - ARM64_SYS_REG(3, 0, 0, 2, 2)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar3, - ARM64_SYS_REG(3, 0, 0, 2, 3)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar4, - ARM64_SYS_REG(3, 0, 0, 2, 4)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar5, - ARM64_SYS_REG(3, 0, 0, 2, 5)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr4, - ARM64_SYS_REG(3, 0, 0, 2, 6)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar6, - ARM64_SYS_REG(3, 0, 0, 2, 7)); - - err |= read_sys_reg32(fdarray[2], &ahcf->isar.mvfr0, - ARM64_SYS_REG(3, 0, 0, 3, 0)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.mvfr1, - ARM64_SYS_REG(3, 0, 0, 3, 1)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.mvfr2, - ARM64_SYS_REG(3, 0, 0, 3, 2)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr2, - ARM64_SYS_REG(3, 0, 0, 3, 4)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_dfr1, - ARM64_SYS_REG(3, 0, 0, 3, 5)); - err |= 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) >= 2) { - int wrps = FIELD_EX64(ahcf->isar.id_aa64dfr0, ID_AA64DFR0, WRPS); - int brps = FIELD_EX64(ahcf->isar.id_aa64dfr0, ID_AA64DFR0, BRPS); - int ctx_cmps = - FIELD_EX64(ahcf->isar.id_aa64dfr0, ID_AA64DFR0, CTX_CMPS); - int version = 6; /* ARMv8 debug architecture */ - bool has_el3 = - !!FIELD_EX32(ahcf->isar.id_aa64pfr0, ID_AA64PFR0, EL3); - uint32_t dbgdidr = 0; - - dbgdidr = FIELD_DP32(dbgdidr, DBGDIDR, WRPS, wrps); - dbgdidr = FIELD_DP32(dbgdidr, DBGDIDR, BRPS, brps); - dbgdidr = FIELD_DP32(dbgdidr, DBGDIDR, CTX_CMPS, ctx_cmps); - dbgdidr = FIELD_DP32(dbgdidr, DBGDIDR, VERSION, version); - dbgdidr = FIELD_DP32(dbgdidr, DBGDIDR, NSUHD_IMP, has_el3); - dbgdidr = FIELD_DP32(dbgdidr, DBGDIDR, SE_IMP, has_el3); - dbgdidr |= (1 << 15); /* RES1 bit */ - ahcf->isar.dbgdidr = dbgdidr; - } - - if (pmu_supported) { - /* PMCR_EL0 is only accessible if the vCPU has feature PMU_V3 */ - err |= 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 73433762fcae - * and f81cb2c3ad41 which have a bug where the kernel doesn't - * expose SYS_ID_AA64ZFR0_EL1 via the ONE_REG API unless the VM 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 |= 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 |= 1ULL << ARM_FEATURE_V8; - features |= 1ULL << ARM_FEATURE_NEON; - features |= 1ULL << ARM_FEATURE_AARCH64; - features |= 1ULL << ARM_FEATURE_PMU; - features |= 1ULL << ARM_FEATURE_GENERIC_TIMER; - - ahcf->features = features; - - return true; -} - -void kvm_arm_steal_time_finalize(ARMCPU *cpu, Error **errp) -{ - bool has_steal_time = kvm_arm_steal_time_supported(); - - if (cpu->kvm_steal_time == ON_OFF_AUTO_AUTO) { - if (!has_steal_time || !arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { - cpu->kvm_steal_time = ON_OFF_AUTO_OFF; - } else { - cpu->kvm_steal_time = ON_OFF_AUTO_ON; - } - } else if (cpu->kvm_steal_time == 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 != 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 = 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 = { - .target = -1, - .features[0] = (1 << KVM_ARM_VCPU_SVE), - }; - struct kvm_one_reg reg = { - .id = KVM_REG_ARM64_SVE_VLS, - .addr = (uint64_t)&vls[0], - }; - int fdarray[3], ret; - - probed = true; - - if (!kvm_arm_create_scratch_host_vcpu(NULL, fdarray, &init)) { - error_report("failed to create scratch VCPU with SVE enabled"); - abort(); - } - ret = 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 = KVM_ARM64_SVE_VLS_WORDS - 1; i >= 0; --i) { - if (vls[i]) { - vq = 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] &= MAKE_64BIT_MASK(0, ARM_MAX_VQ); - } - } - - return vls[0]; -} - -static int kvm_arm_sve_set_vls(CPUState *cs) -{ - ARMCPU *cpu = ARM_CPU(cs); - uint64_t vls[KVM_ARM64_SVE_VLS_WORDS] = { cpu->sve_vq.map }; - struct kvm_one_reg reg = { - .id = KVM_REG_ARM64_SVE_VLS, - .addr = (uint64_t)&vls[0], - }; - - assert(cpu->sve_max_vq <= 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 = ARM_CPU(cs); - CPUARMState *env = &cpu->env; - uint64_t psciver; - - if (cpu->kvm_target == 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] |= 1 << KVM_ARM_VCPU_POWER_OFF; - } - if (kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PSCI_0_2)) { - cpu->psci_version = QEMU_PSCI_VERSION_0_2; - cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_PSCI_0_2; - } - if (!arm_feature(&cpu->env, ARM_FEATURE_AARCH64)) { - cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_EL1_32BIT; - } - if (!kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PMU_V3)) { - cpu->has_pmu = false; - } - if (cpu->has_pmu) { - cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_PMU_V3; - } else { - env->features &= ~(1ULL << ARM_FEATURE_PMU); - } - if (cpu_isar_feature(aa64_sve, cpu)) { - assert(kvm_arm_sve_supported()); - cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_SVE; - } - if (cpu_isar_feature(aa64_pauth, cpu)) { - cpu->kvm_init_features[0] |= (1 << KVM_ARM_VCPU_PTRAUTH_ADDRESS | - 1 << KVM_ARM_VCPU_PTRAUTH_GENERIC); - } - - /* Do KVM_ARM_VCPU_INIT ioctl */ - ret = kvm_arm_vcpu_init(cs); - if (ret) { - return ret; - } - - if (cpu_isar_feature(aa64_sve, cpu)) { - ret = kvm_arm_sve_set_vls(cs); - if (ret) { - return ret; - } - ret = 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 = 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 = 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[] = { - { KVM_REG_ARM_TIMER_CNT, KVM_PUT_FULL_STATE }, -}; - -int kvm_arm_cpreg_level(uint64_t regidx) -{ - int i; - - for (i = 0; i < ARRAY_SIZE(non_runtime_cpregs); i++) { - const CPRegStateLevel *l = &non_runtime_cpregs[i]; - if (l->regidx == 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 = ARM_CPU(c); - CPUARMState *env = &cpu->env; - uint32_t esr; - bool same_el; - - c->exception_index = EXCP_DATA_ABORT; - env->exception.target_el = 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 = arm_current_el(env) == env->exception.target_el; - esr = syn_data_abort_no_iss(same_el, 1, 0, 0, 0, 0, 0x10); - - env->exception.syndrome = 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 = &ARM_CPU(cs)->env; - struct kvm_one_reg reg; - int i, ret; - - for (i = 0; i < 32; i++) { - uint64_t *q = aa64_vfp_qreg(env, i); -#if HOST_BIG_ENDIAN - uint64_t fp_val[2] = { q[1], q[0] }; - reg.addr = (uintptr_t)fp_val; -#else - reg.addr = (uintptr_t)q; -#endif - reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); - ret = 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 than - * one slice for quite some time. - */ -static int kvm_arch_put_sve(CPUState *cs) -{ - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; - uint64_t tmp[ARM_MAX_VQ * 2]; - uint64_t *r; - struct kvm_one_reg reg; - int n, ret; - - for (n = 0; n < KVM_ARM64_SVE_NUM_ZREGS; ++n) { - r = sve_bswap64(tmp, &env->vfp.zregs[n].d[0], cpu->sve_max_vq * 2); - reg.addr = (uintptr_t)r; - reg.id = KVM_REG_ARM64_SVE_ZREG(n, 0); - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); - if (ret) { - return ret; - } - } - - for (n = 0; n < KVM_ARM64_SVE_NUM_PREGS; ++n) { - r = sve_bswap64(tmp, r = &env->vfp.pregs[n].p[0], - DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); - reg.addr = (uintptr_t)r; - reg.id = KVM_REG_ARM64_SVE_PREG(n, 0); - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); - if (ret) { - return ret; - } - } - - r = sve_bswap64(tmp, &env->vfp.pregs[FFR_PRED_NUM].p[0], - DIV_ROUND_UP(cpu->sve_max_vq * 2, 8)); - reg.addr = (uintptr_t)r; - reg.id = KVM_REG_ARM64_SVE_FFR(0); - ret = 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 = ARM_CPU(cs); - CPUARMState *env = &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 = 0; i < 31; i++) { - reg.id = AARCH64_CORE_REG(regs.regs[i]); - reg.addr = (uintptr_t) &env->xregs[i]; - ret = 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 = AARCH64_CORE_REG(regs.sp); - reg.addr = (uintptr_t) &env->sp_el[0]; - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); - if (ret) { - return ret; - } - - reg.id = AARCH64_CORE_REG(sp_el1); - reg.addr = (uintptr_t) &env->sp_el[1]; - ret = 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 = pstate_read(env); - } else { - val = cpsr_read(env); - } - reg.id = AARCH64_CORE_REG(regs.pstate); - reg.addr = (uintptr_t) &val; - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); - if (ret) { - return ret; - } - - reg.id = AARCH64_CORE_REG(regs.pc); - reg.addr = (uintptr_t) &env->pc; - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); - if (ret) { - return ret; - } - - reg.id = AARCH64_CORE_REG(elr_el1); - reg.addr = (uintptr_t) &env->elr_el[1]; - ret = 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 = arm_current_el(env); - if (el > 0 && !is_a64(env)) { - i = bank_number(env->uncached_cpsr & CPSR_M); - env->banked_spsr[i] = env->spsr; - } - - /* KVM 0-4 map to QEMU banks 1-5 */ - for (i = 0; i < KVM_NR_SPSR; i++) { - reg.id = AARCH64_CORE_REG(spsr[i]); - reg.addr = (uintptr_t) &env->banked_spsr[i + 1]; - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); - if (ret) { - return ret; - } - } - - if (cpu_isar_feature(aa64_sve, cpu)) { - ret = kvm_arch_put_sve(cs); - } else { - ret = kvm_arch_put_fpsimd(cs); - } - if (ret) { - return ret; - } - - reg.addr = (uintptr_t)(&fpr); - fpr = vfp_get_fpsr(env); - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); - ret = kvm_vcpu_ioctl(cs, KVM_SET_ONE_REG, ®); - if (ret) { - return ret; - } - - reg.addr = (uintptr_t)(&fpr); - fpr = vfp_get_fpcr(env); - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); - ret = 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 = 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 = &ARM_CPU(cs)->env; - struct kvm_one_reg reg; - int i, ret; - - for (i = 0; i < 32; i++) { - uint64_t *q = aa64_vfp_qreg(env, i); - reg.id = AARCH64_SIMD_CORE_REG(fp_regs.vregs[i]); - reg.addr = (uintptr_t)q; - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } else { -#if HOST_BIG_ENDIAN - uint64_t t; - t = q[0], q[0] = q[1], q[1] = 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 than - * one slice for quite some time. - */ -static int kvm_arch_get_sve(CPUState *cs) -{ - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &cpu->env; - struct kvm_one_reg reg; - uint64_t *r; - int n, ret; - - for (n = 0; n < KVM_ARM64_SVE_NUM_ZREGS; ++n) { - r = &env->vfp.zregs[n].d[0]; - reg.addr = (uintptr_t)r; - reg.id = KVM_REG_ARM64_SVE_ZREG(n, 0); - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } - sve_bswap64(r, r, cpu->sve_max_vq * 2); - } - - for (n = 0; n < KVM_ARM64_SVE_NUM_PREGS; ++n) { - r = &env->vfp.pregs[n].p[0]; - reg.addr = (uintptr_t)r; - reg.id = KVM_REG_ARM64_SVE_PREG(n, 0); - ret = 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 = &env->vfp.pregs[FFR_PRED_NUM].p[0]; - reg.addr = (uintptr_t)r; - reg.id = KVM_REG_ARM64_SVE_FFR(0); - ret = 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 = ARM_CPU(cs); - CPUARMState *env = &cpu->env; - - for (i = 0; i < 31; i++) { - reg.id = AARCH64_CORE_REG(regs.regs[i]); - reg.addr = (uintptr_t) &env->xregs[i]; - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } - } - - reg.id = AARCH64_CORE_REG(regs.sp); - reg.addr = (uintptr_t) &env->sp_el[0]; - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } - - reg.id = AARCH64_CORE_REG(sp_el1); - reg.addr = (uintptr_t) &env->sp_el[1]; - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } - - reg.id = AARCH64_CORE_REG(regs.pstate); - reg.addr = (uintptr_t) &val; - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } - - env->aarch64 = ((val & PSTATE_nRW) == 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 = AARCH64_CORE_REG(regs.pc); - reg.addr = (uintptr_t) &env->pc; - ret = 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 with 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 = AARCH64_CORE_REG(elr_el1); - reg.addr = (uintptr_t) &env->elr_el[1]; - ret = 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 = 0; i < KVM_NR_SPSR; i++) { - reg.id = AARCH64_CORE_REG(spsr[i]); - reg.addr = (uintptr_t) &env->banked_spsr[i + 1]; - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } - } - - el = arm_current_el(env); - if (el > 0 && !is_a64(env)) { - i = bank_number(env->uncached_cpsr & CPSR_M); - env->spsr = env->banked_spsr[i]; - } - - if (cpu_isar_feature(aa64_sve, cpu)) { - ret = kvm_arch_get_sve(cs); - } else { - ret = kvm_arch_get_fpsimd(cs); - } - if (ret) { - return ret; - } - - reg.addr = (uintptr_t)(&fpr); - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpsr); - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } - vfp_set_fpsr(env, fpr); - - reg.addr = (uintptr_t)(&fpr); - reg.id = AARCH64_SIMD_CTRL_REG(fp_regs.fpcr); - ret = kvm_vcpu_ioctl(cs, KVM_GET_ONE_REG, ®); - if (ret) { - return ret; - } - vfp_set_fpcr(env, fpr); - - ret = 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 == BUS_MCEERR_AR || code == BUS_MCEERR_AO); - - if (acpi_ghes_present() && addr) { - ram_addr = qemu_ram_addr_from_host(addr); - if (ram_addr != 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 == 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 == BUS_MCEERR_AO) { - error_report("Hardware memory error at addr %p for memory used by " - "QEMU itself instead of guest system!", addr); - } - } - - if (code == BUS_MCEERR_AR) { - error_report("Hardware memory error!"); - exit(1); - } -} - -/* C6.6.29 BRK instruction */ -static const uint32_t brk_insn = 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 != 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 = syn_get_ec(debug_exit->hsr); - ARMCPU *cpu = ARM_CPU(cs); - CPUARMState *env = &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 unsupported" - " (%"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 = find_hw_watchpoint(cs, debug_exit->far); - if (wp) { - cs->watchpoint_hit = 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 = EXCP_BKPT; - env->exception.syndrome = debug_exit->hsr; - env->exception.vaddress = debug_exit->far; - env->exception.target_el = 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 == 0 - * FS[4] - DFSR[10] - * FS[3:0] - DFSR[3:0] - * TTBCR.EAE == 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 = ARM_CPU(cs); - CPUARMState *env = &cpu->env; - int aarch64_mode = arm_feature(env, ARM_FEATURE_AARCH64); - int lpae = 0; - - if (!aarch64_mode) { - uint64_t ttbcr; - - if (!kvm_get_one_reg(cs, ARM64_REG_TCR_EL1, &ttbcr)) { - lpae = 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) == - 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) -arm_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c', 'kvm64.c'), if_false: files('kvm-stub.c')) +arm_ss.add(when: 'CONFIG_KVM', if_true: files('kvm.c'), if_false: files('kvm-stub.c')) arm_ss.add(when: 'TARGET_AARCH64', if_true: files( 'cpu64.c', From patchwork Tue Jan 3 18:16:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638732 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1391054pvb; Tue, 3 Jan 2023 10:19:24 -0800 (PST) X-Google-Smtp-Source: AMrXdXt5vapkEMENHcQYglv0CMuVQl/Lx1CjT55/OwkwQXCCSK2YZomw/rQJ5wqjRXYRFBu9G7F4 X-Received: by 2002:ac8:5448:0:b0:3ab:6cf1:1e67 with SMTP id d8-20020ac85448000000b003ab6cf11e67mr55017662qtq.4.1672769964743; Tue, 03 Jan 2023 10:19:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672769964; cv=none; d=google.com; s=arc-20160816; b=Cz/FM71RPX2t/N9Gwt2HLKphhR6X0CCKaKJJSqC1samvh6dbbChwIxY96AMK22vTDz Sz5yZycs/PrhIMzwaUtUy6IdqYHdA+gqi8Qe4gsrWtA0Ar+NECx1Iya65RH8it101Ek4 WxWKZTMXPqm+sfYNkHnJ2h+NoG00ZDQzQ9tDfHmjR7Q87mEy2EShy15Qfc45ea5t2Aj2 806+ehCEI1BPcs4n0TLE18QYMg43gm7aqtERzwBqLD6LBwdf93gJPvvOSOC8Yqqte/hC NqYoKHdKY3DIKE7fYk+VXBtv2CrQzepkqc5d1CZyPxk1NEdIro/WQN95S1geh7Hj9RyR xBPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=DDbFWUAdD66ccbGgAfeLRZAs/Smk+GVAFx7IHK4amAk=; b=wUZOq8h4a56kHntMRyowyDFqmARYbwBsDBUXV8uiMHHflVh2xeOwp6WXMhVWnTJSXv L03jt8/vADKqs6127OsKn2KmkVJWOoXNNkQfs96fYE8ObcIeuHM/YgHRDR/AwQNRbWDE Hl759IXUiS2zMJaTA6S4f81uyGi3Zg7BgULQ0wYfR9JtUSs8wot7ocx5oBpcCO4u8RoB sBEel0JzHHHkRPHtCgzIcSThLFW6RINFwj6mkWRJbDkZJevMSzSTdLxxtrwhVlAibmMQ jPj9XBDtXcdBBbwsfSomDdWavdzqBwz46J3VLCJTFkraFRsAOecgDRNBi8ivDhhCg29i Csug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QIfFCDIx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id bw13-20020a05622a098d00b003a6a5866c2esi17132988qtb.171.2023.01.03.10.19.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:19:24 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=QIfFCDIx; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org Since kvm32 was removed, all kvm hosts support aarch64. Signed-off-by: Richard Henderson Reviewed-by: Philippe Mathieu-Daudé --- 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 = 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 = ARM_CPU(obj); hvf_arm_set_cpu_features_from_host(cpu); From patchwork Tue Jan 3 18:16:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638729 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1390884pvb; Tue, 3 Jan 2023 10:18:57 -0800 (PST) X-Google-Smtp-Source: AMrXdXujx1Dx/hy7j+MIY4BZdxQxvvFIeACMpU1AzT+uvEy3fjsqUywd82mZCcWdEFYVInt7xPUN X-Received: by 2002:a0c:d792:0:b0:4c7:971e:3c05 with SMTP id z18-20020a0cd792000000b004c7971e3c05mr58782980qvi.36.1672769936868; Tue, 03 Jan 2023 10:18:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672769936; cv=none; d=google.com; s=arc-20160816; b=lEip6KWfvA4+Ju2ltfsPSbbTz6PgNlXlDlSkBCrdgp7G3ok3Qp0/ttT2OE270R1NFm fi1NbnaJLyGrdCcXHJ9qeBWGU2B7opXsR/NymvzPNVbMJ1rhfxpm5NSVA0PFjahC1Osw PGGV5NhkIy3hF5MKfAGuWLU5/tDqTNseoBFf31AZDOaubZM1Y1z12aptsRGBrVf8KTlT cFAN+/+AFJclkSBVCLEJZNbQhu05B7tO9f9gjC9s4357cxBu6N+P3n1jFtKKmSSU7AuF p6vOvAvg6Y/d2NyjLT1d9VoTk608GUOAIFDbyfOLPGq2kKNz2PlsN/95/XKbCZnrX6ce K9hQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Giw+JXSeEeudG8bVmdhTP6eAIZIod5pTf9XSXTJ4xZQ=; b=TQT4I4HmVMR1lglOF3oM09639TTBKjo0SmdlZvkDVvxaXP4XytV094L49ddlzYVkXT Ez65gd8Gg69JuoKRCz0FiPA3UCG9Zkq1XwIFUmQJz+GzfgduVO/nfp8e5JyEF+/Hdvwu qZrdMIYmb2huhqDDRkQ59nSB71QNZeNwfQ0ge3WXVOucN5L37oij37Xi6Lbs7iR0k3wu i9hBvJ+yTFzBUOrbJpdn6zTQ3+axwHeywFD+1fCSl+EPj7GtEiCFPPKA2SHZgpcJWIdQ D0irCJZWYFrqtQ/Cdl5CLtoLi1YAxxEW4V/tFQ4UaEBi9Bqyyq/xOArICdWijl7i4kjl E3xA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f6LPjggl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id iy5-20020a0562140f6500b004990359d3aasi16077842qvb.462.2023.01.03.10.18.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:18:56 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=f6LPjggl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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(ARMCPUClass *cpu) cpu->isar.reset_pmcr_el0 = 0x410c3000; } +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 = "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; } - /* '-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 = "arm,arm-v8"; /* * Reset MIDR so the guest doesn't mistake our 'max' CPU type for a real @@ -1316,10 +1335,12 @@ static const ARMCPUInfo aarch64_cpus[] = { .class_init = aarch64_a64fx_class_init, .object_init = aarch64_a64fx_object_init }, { .name = "max", + .class_init = aarch64_host_class_init, .class_late_init = aarch64_max_class_late_init, .object_init = aarch64_max_object_init }, #if defined(CONFIG_KVM) || defined(CONFIG_HVF) { .name = "host", + .class_init = aarch64_host_class_init, .object_init = 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; typedef struct ARMHostCPUFeatures { ARMISARegisters isar; - uint64_t features; uint64_t midr; uint32_t reset_sctlr; - const char *dtb_compatible; } ARMHostCPUFeatures; static ARMHostCPUFeatures arm_host_cpu_features; @@ -489,13 +487,6 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) hv_vcpu_exit_t *exit; int i; - ahcf->dtb_compatible = "arm,arm-v8"; - ahcf->features = (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 */ if (hv_vcpu_create(&fd, &exit, NULL) != HV_SUCCESS) { @@ -532,7 +523,7 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) 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) } } - cpu->dtb_compatible = arm_host_cpu_features.dtb_compatible; cpu->isar = arm_host_cpu_features.isar; - cpu->env.features = arm_host_cpu_features.features; cpu->midr = arm_host_cpu_features.midr; cpu->reset_sctlr = 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; static ARMHostCPUFeatures arm_host_cpu_features; @@ -1567,7 +1565,6 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) int fdarray[3]; bool sve_supported; bool pmu_supported = false; - uint64_t features = 0; int err; /* Old kernels may not know about the PREFERRED_TARGET ioctl: however @@ -1615,7 +1612,6 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) } ahcf->target = init.target; - ahcf->dtb_compatible = "arm,arm-v8"; err = 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(ARMHostCPUFeatures *ahcf) 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 |= 1ULL << ARM_FEATURE_V8; - features |= 1ULL << ARM_FEATURE_NEON; - features |= 1ULL << ARM_FEATURE_AARCH64; - features |= 1ULL << ARM_FEATURE_PMU; - features |= 1ULL << ARM_FEATURE_GENERIC_TIMER; - - ahcf->features = features; - - return true; + return !err; } void kvm_arm_set_cpu_features_from_host(ARMCPU *cpu) { - CPUARMState *env = &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) } cpu->kvm_target = arm_host_cpu_features.target; - cpu->dtb_compatible = arm_host_cpu_features.dtb_compatible; cpu->isar = arm_host_cpu_features.isar; - env->features = arm_host_cpu_features.features; } /** From patchwork Tue Jan 3 18:16:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638752 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1393709pvb; Tue, 3 Jan 2023 10:26:24 -0800 (PST) X-Google-Smtp-Source: AMrXdXsjRLqkclYAUqFsAZ61NcCS6nr14aBLeNHRqH2uv4hBx5IRfIs1Or9YC0bKRnRnj4x7VhJh X-Received: by 2002:a0c:eb86:0:b0:531:97a3:90a with SMTP id x6-20020a0ceb86000000b0053197a3090amr34055142qvo.4.1672770383788; Tue, 03 Jan 2023 10:26:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770383; cv=none; d=google.com; s=arc-20160816; b=FVaDNyu6tlMwh8jSexTFLNc2vqlhzc69MZxVl+Q1Gc8qhcwSV/ub0WKf62+3sekTjx vBnrMu8KbXzw2Eo31f076XZ6tMD7VPmtonNeHaqo8bXNXo84jzF/Uebf05+6CLknFsX8 9k8F8Y6+HxnW2EL5v2LAaeUgmhpPLxWWFX4GiHpYmaoeCeDnmCCH7ytEvE4AzGKcJotU +UllxwfRd6lx0WWMPx80t00Q8yRN4nRgb620qfR/JLqjEkj9xOnfdEzDzX0LBi0HLdxu makKgmSDnDvjD5SQUsMwYafEcj69yoaXNAhPizsYxw9tDtzawFgfKLeTfr+9D6VRHO66 gaIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=/jTn1GxLrxhP97RklVZOWNe5snNH2L7l/ITGnN9gIBg=; b=ym17wX5DpGD8zCbwXqOhLn1PTGHrnQcD9bzP39X1VEDEvFM+odzSCFFoALXb2F4Xa4 KvwG5qJ+d0qtYw0IYhZWrW5v2GP5CLVK5VM/jqOP5xKyRx4GmhxpNfS3VkZTOVGPlHhk d+Ije++FdpsZhh31TcBxH+VqGCxvL+0ZQ1drer6bsjHmOfU1jrdKwM6cdrybiCE9m8La IVkYIsZXw11GWy4XjyYpmA/MQihuSEJx6IFc5Y+9pXUZclhjFUEYCiHlzdqYnrARqvq1 +7u2CUJucD9i9UucLXu6GsoJyqUQ823X8THFW0qG0JrKmaRRHdmXp1J5iYIVQMgHFjMH gTug== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SeY7fHcl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id t10-20020a05620a450a00b006fed0dc6807si17970409qkp.527.2023.01.03.10.26.23 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:26:23 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SeY7fHcl; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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); /** - * 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); /** * 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 *acc) set_class_feature(acc, ARM_FEATURE_PMU); } +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 = 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; 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); } /* @@ -1341,6 +1352,7 @@ static const ARMCPUInfo aarch64_cpus[] = { #if defined(CONFIG_KVM) || defined(CONFIG_HVF) { .name = "host", .class_init = aarch64_host_class_init, + .class_late_init = aarch64_host_class_late_init, .object_init = 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; -/** - * 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) /** * 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(ARMHostCPUFeatures *ahcf) } if (!kvm_arm_create_scratch_host_vcpu(cpus_to_try, fdarray, &init)) { + error_setg_errno(errp, "Failed to create host vcpu"); + acc->kvm_target = QEMU_KVM_ARM_TARGET_NONE; return false; } - ahcf->target = init.target; + acc->kvm_target = init.target; - err = read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64pfr0, + err = 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(ARMHostCPUFeatures *ahcf) * ??? Either of these sounds like too much effort just * to work around running a modern host kernel. */ - ahcf->isar.id_aa64pfr0 = 0x00000011; /* EL1&0, AArch64 only */ + acc->isar.id_aa64pfr0 = 0x00000011; /* EL1&0, AArch64 only */ err = 0; } else { - err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64pfr1, + err |= read_sys_reg64(fdarray[2], &acc->isar.id_aa64pfr1, ARM64_SYS_REG(3, 0, 0, 4, 1)); - err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64smfr0, + err |= read_sys_reg64(fdarray[2], &acc->isar.id_aa64smfr0, ARM64_SYS_REG(3, 0, 0, 4, 5)); - err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64dfr0, + err |= read_sys_reg64(fdarray[2], &acc->isar.id_aa64dfr0, ARM64_SYS_REG(3, 0, 0, 5, 0)); - err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64dfr1, + err |= read_sys_reg64(fdarray[2], &acc->isar.id_aa64dfr1, ARM64_SYS_REG(3, 0, 0, 5, 1)); - err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64isar0, + err |= read_sys_reg64(fdarray[2], &acc->isar.id_aa64isar0, ARM64_SYS_REG(3, 0, 0, 6, 0)); - err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64isar1, + err |= read_sys_reg64(fdarray[2], &acc->isar.id_aa64isar1, ARM64_SYS_REG(3, 0, 0, 6, 1)); - err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr0, + err |= read_sys_reg64(fdarray[2], &acc->isar.id_aa64mmfr0, ARM64_SYS_REG(3, 0, 0, 7, 0)); - err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr1, + err |= read_sys_reg64(fdarray[2], &acc->isar.id_aa64mmfr1, ARM64_SYS_REG(3, 0, 0, 7, 1)); - err |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64mmfr2, + err |= read_sys_reg64(fdarray[2], &acc->isar.id_aa64mmfr2, ARM64_SYS_REG(3, 0, 0, 7, 2)); /* @@ -1661,48 +1652,48 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) * than skipping the reads and leaving 0, as we must avoid * considering the values in every case. */ - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr0, + err |= read_sys_reg32(fdarray[2], &acc->isar.id_pfr0, ARM64_SYS_REG(3, 0, 0, 1, 0)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr1, + err |= read_sys_reg32(fdarray[2], &acc->isar.id_pfr1, ARM64_SYS_REG(3, 0, 0, 1, 1)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_dfr0, + err |= read_sys_reg32(fdarray[2], &acc->isar.id_dfr0, ARM64_SYS_REG(3, 0, 0, 1, 2)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr0, + err |= read_sys_reg32(fdarray[2], &acc->isar.id_mmfr0, ARM64_SYS_REG(3, 0, 0, 1, 4)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr1, + err |= read_sys_reg32(fdarray[2], &acc->isar.id_mmfr1, ARM64_SYS_REG(3, 0, 0, 1, 5)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr2, + err |= read_sys_reg32(fdarray[2], &acc->isar.id_mmfr2, ARM64_SYS_REG(3, 0, 0, 1, 6)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr3, + err |= read_sys_reg32(fdarray[2], &acc->isar.id_mmfr3, ARM64_SYS_REG(3, 0, 0, 1, 7)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar0, + err |= read_sys_reg32(fdarray[2], &acc->isar.id_isar0, ARM64_SYS_REG(3, 0, 0, 2, 0)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar1, + err |= read_sys_reg32(fdarray[2], &acc->isar.id_isar1, ARM64_SYS_REG(3, 0, 0, 2, 1)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar2, + err |= read_sys_reg32(fdarray[2], &acc->isar.id_isar2, ARM64_SYS_REG(3, 0, 0, 2, 2)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar3, + err |= read_sys_reg32(fdarray[2], &acc->isar.id_isar3, ARM64_SYS_REG(3, 0, 0, 2, 3)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar4, + err |= read_sys_reg32(fdarray[2], &acc->isar.id_isar4, ARM64_SYS_REG(3, 0, 0, 2, 4)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar5, + err |= read_sys_reg32(fdarray[2], &acc->isar.id_isar5, ARM64_SYS_REG(3, 0, 0, 2, 5)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr4, + err |= read_sys_reg32(fdarray[2], &acc->isar.id_mmfr4, ARM64_SYS_REG(3, 0, 0, 2, 6)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_isar6, + err |= read_sys_reg32(fdarray[2], &acc->isar.id_isar6, ARM64_SYS_REG(3, 0, 0, 2, 7)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.mvfr0, + err |= read_sys_reg32(fdarray[2], &acc->isar.mvfr0, ARM64_SYS_REG(3, 0, 0, 3, 0)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.mvfr1, + err |= read_sys_reg32(fdarray[2], &acc->isar.mvfr1, ARM64_SYS_REG(3, 0, 0, 3, 1)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.mvfr2, + err |= read_sys_reg32(fdarray[2], &acc->isar.mvfr2, ARM64_SYS_REG(3, 0, 0, 3, 2)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_pfr2, + err |= read_sys_reg32(fdarray[2], &acc->isar.id_pfr2, ARM64_SYS_REG(3, 0, 0, 3, 4)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_dfr1, + err |= read_sys_reg32(fdarray[2], &acc->isar.id_dfr1, ARM64_SYS_REG(3, 0, 0, 3, 5)); - err |= read_sys_reg32(fdarray[2], &ahcf->isar.id_mmfr5, + err |= read_sys_reg32(fdarray[2], &acc->isar.id_mmfr5, ARM64_SYS_REG(3, 0, 0, 3, 6)); /* @@ -1715,14 +1706,14 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *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) >= 2) { - int wrps = FIELD_EX64(ahcf->isar.id_aa64dfr0, ID_AA64DFR0, WRPS); - int brps = FIELD_EX64(ahcf->isar.id_aa64dfr0, ID_AA64DFR0, BRPS); + if (FIELD_EX32(acc->isar.id_aa64pfr0, ID_AA64PFR0, EL1) >= 2) { + int wrps = FIELD_EX64(acc->isar.id_aa64dfr0, ID_AA64DFR0, WRPS); + int brps = FIELD_EX64(acc->isar.id_aa64dfr0, ID_AA64DFR0, BRPS); int ctx_cmps = - FIELD_EX64(ahcf->isar.id_aa64dfr0, ID_AA64DFR0, CTX_CMPS); + FIELD_EX64(acc->isar.id_aa64dfr0, ID_AA64DFR0, CTX_CMPS); int version = 6; /* ARMv8 debug architecture */ bool has_el3 = - !!FIELD_EX32(ahcf->isar.id_aa64pfr0, ID_AA64PFR0, EL3); + !!FIELD_EX32(acc->isar.id_aa64pfr0, ID_AA64PFR0, EL3); uint32_t dbgdidr = 0; dbgdidr = FIELD_DP32(dbgdidr, DBGDIDR, WRPS, wrps); @@ -1732,12 +1723,12 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) dbgdidr = FIELD_DP32(dbgdidr, DBGDIDR, NSUHD_IMP, has_el3); dbgdidr = FIELD_DP32(dbgdidr, DBGDIDR, SE_IMP, has_el3); dbgdidr |= (1 << 15); /* RES1 bit */ - ahcf->isar.dbgdidr = dbgdidr; + acc->isar.dbgdidr = dbgdidr; } if (pmu_supported) { /* PMCR_EL0 is only accessible if the vCPU has feature PMU_V3 */ - err |= read_sys_reg64(fdarray[2], &ahcf->isar.reset_pmcr_el0, + err |= read_sys_reg64(fdarray[2], &acc->isar.reset_pmcr_el0, ARM64_SYS_REG(3, 3, 9, 12, 0)); } @@ -1749,7 +1740,7 @@ static bool kvm_arm_get_host_cpu_features(ARMHostCPUFeatures *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 |= read_sys_reg64(fdarray[2], &ahcf->isar.id_aa64zfr0, + err |= 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(ARMHostCPUFeatures *ahcf) return !err; } -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 = QEMU_KVM_ARM_TARGET_NONE; - cpu->host_cpu_probe_failed = true; - return; - } - } - - cpu->kvm_target = arm_host_cpu_features.target; - cpu->isar = arm_host_cpu_features.isar; -} - /** * kvm_arm_steal_time_supported: * From patchwork Tue Jan 3 18:16:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638760 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1394502pvb; Tue, 3 Jan 2023 10:28:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXsasJM9ArHQyvhGr4VhGzdZiFA+XckPqpUuNY2bq6j7r0pHsYzhMXp48IuRfdKSa4G/oU+H X-Received: by 2002:ac8:51d4:0:b0:3a8:1677:bc46 with SMTP id d20-20020ac851d4000000b003a81677bc46mr61953907qtn.49.1672770506777; Tue, 03 Jan 2023 10:28:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770506; cv=none; d=google.com; s=arc-20160816; b=JC+czGpbr0yQoz9E5z1QVBFXkC9vSxUiKhv595O53teEr35LH2mgis+nja2rhQXEfl OrHrLSvqO0UZzZ3L3LULLCkDc0+AgAOhwqUBVEg/XqRmPz7n9LxPWAoFKhUWzbC6SU8B sGDPSnit1IuMtd+bNhCi9f7yFdCxPp1mMlokvKj2RF/7KXU81r7LQ8M7jqKVbqpEpvAm Y7iDNQB9BbuwfjQy4F7dzLF1ArdhMgf/GpCzgn28/Oq/jtQ4zLH7+Aq6KzkiRWuo4/8e ZGH6ZzfDCo3PNOLnf/HhWf/TAo597Jmipd+BoRRo/EddeF9TlDhE/58kc+yRCsBRXUzm iBKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=YMcPmZrXvRwclxq0TRDUHuwzEJ3xWsfRZYvLnaachU4=; b=um817xG1wwrbr249MmDAAL1UT9KJJhupYeLYYTh7fvq3sZuVmr8rcgqBYGjbCSKtW+ dIVh3a9sr7pMoIEtDEyXGJU+RjDgqsybszRgTPTekYPqwxFQa6W+f5r7gtwGgO//ZQmd zIYGxln6AZD3Uhim53ZWvnRPOJQ6Y70NQJ2oLBORqNWaJbDIO7tO1QhiTqiffnCHCgP4 leffxTmeLH+hUfUFEAPECWjbWSk3Se0si9RYkk7UTnfCMPKSUneYgvDISgeRVlkczHZQ 0alcX5SrHOoXsxgkMg7b481Q9MPLl+XVn7EKLqR5sTjuMQBUOKvZqHACuUExRIoEJ9kF +Wzw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SHjFVrXW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e27-20020a05620a015b00b006fec79dd6adsi16107714qkn.390.2023.01.03.10.28.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:28:26 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=SHjFVrXW; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 Received-SPF: pass client-ip=2607:f8b0:4864:20::a2d; envelope-from=richard.henderson@linaro.org; helo=mail-vk1-xa2d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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; - /* True if we tried kvm_arm_host_cpu_features() during CPU instance_init - * 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 @@ #include "cpu.h" -void hvf_arm_set_cpu_features_from_host(ARMCPU *cpu); +bool hvf_arm_get_host_cpu_features(ARMCPUClass *acc, Error **errp); #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, Error **errp) Error *local_err = NULL; bool no_aa32 = false; - /* 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 KVM 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 = 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 { static HVFVTimer vtimer; -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; } -static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) +bool hvf_arm_get_host_cpu_features(ARMCPUClass *acc, Error **errp) { - ARMISARegisters host_isar = {}; const struct isar_regs { int reg; uint64_t *val; } regs[] = { - { 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 = HV_SUCCESS; @@ -496,50 +487,30 @@ static bool hvf_arm_get_host_cpu_features(ARMHostCPUFeatures *ahcf) for (i = 0; i < ARRAY_SIZE(regs); i++) { r |= hv_vcpu_get_sys_reg(fd, regs[i].reg, regs[i].val); } - r |= hv_vcpu_get_sys_reg(fd, HV_SYS_REG_MIDR_EL1, &ahcf->midr); + r |= hv_vcpu_get_sys_reg(fd, HV_SYS_REG_MIDR_EL1, &acc->midr); r |= hv_vcpu_destroy(fd); - ahcf->isar = 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 = 0x30100180; + acc->reset_sctlr = 0x30100180; + /* * SPAN is disabled by default when SCTLR.SPAN=1. To improve compatibility, * let's disable it on boot and then allow guest software to turn it on by * setting it to 0. */ - ahcf->reset_sctlr |= 0x00800000; + acc->reset_sctlr |= 0x00800000; /* Make sure we don't advertise AArch32 support for EL0/EL1 */ - if ((host_isar.id_aa64pfr0 & 0xff) != 0x11) { + if ((acc->isar.id_aa64pfr0 & 0xff) != 0x11) { return false; } return r == HV_SUCCESS; } -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 = true; - return; - } - } - - cpu->isar = arm_host_cpu_features.isar; - cpu->midr = arm_host_cpu_features.midr; - cpu->reset_sctlr = arm_host_cpu_features.reset_sctlr; -} - void hvf_arch_vcpu_destroy(CPUState *cpu) { } From patchwork Tue Jan 3 18:16:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638754 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1394179pvb; Tue, 3 Jan 2023 10:27:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXvIMk533+fHmJjgT69HUcAAST0JHqCwRYSbB7WH1O+Pjtf9KoNiRJfkkbtlRBe0TvYK0euN X-Received: by 2002:a05:6214:2e07:b0:4f3:7d92:13a9 with SMTP id mx7-20020a0562142e0700b004f37d9213a9mr63164272qvb.15.1672770455370; Tue, 03 Jan 2023 10:27:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770455; cv=none; d=google.com; s=arc-20160816; b=wfvH+z6eNMS3g2s4hwGCzBaqfKGQiJIok0AWt0zQCLEimXCNUjPzmrcFSG0rPnKUdw GvEh/Gb+6npLyGYLR7NT2051w7qoRE8al6bTG0d2iOnnEv+AebsUPsdOAsZqdtOnuNfC zd5iqRuA2a399pISa3YJxK76bE/BRF72ghC1vms19kzw7Mjw8XiAvK74S7moPeeBzInj QuzRkNI9FShRNH8hNqNHfRgqChXkbeoJRvTC/pCjLCEmoV5b+1adJ+sOsWr0OtwIEjQl qPQeOS50BUnnJhDsGi03PtIziiB4uy+RANMQ8kZnqESicUhCdQYcZhBQyzCY/OzdtIl0 5iXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0cpI31q8puiq+k9BfPqvIkCRkk/xl8XaSMre9iCPsr0=; b=sMKK9exElsH5Pd3Q+XcNun5wlikkCCvgLslzz7/XKNSx4+AKxw+C5+tjUXiYUumgXU FdPxVNN/eNNE0xde4Lr8JyukwctsM9WVVY3z7gg4yFQL7lAn2OOy8ukrArGwsJX67p5S lEdAaka3sgofLo1xG6EJG2kco85IJQyAoKKCWaN/om1A3Jj7J+Uf3rZyJrAP5QBxcGLo Vs/XxYLc+rRKVdfIZ44PhGPHop4kCloQiM9ZkxEWGwvePEmTKge0PyOM2nX6PvSi+7EI UQpMnkMvw0nzJmMmXKr40f4cA9dDamhqL/tpsAwC8WbHjkPNdhSmipDWWCdkmapKi8uD 0cGw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sBGvtHN5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id hf12-20020a0562140e8c00b004bc24487e54si16617278qvb.276.2023.01.03.10.27.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:27:35 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sBGvtHN5; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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) 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[] = { - { 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 = HV_SUCCESS; @@ -485,9 +495,9 @@ bool hvf_arm_get_host_cpu_features(ARMCPUClass *acc, Error **errp) } for (i = 0; i < ARRAY_SIZE(regs); i++) { - r |= hv_vcpu_get_sys_reg(fd, regs[i].reg, regs[i].val); + uint64_t *p = (void *)acc + regs[i].offset; + r |= hv_vcpu_get_sys_reg(fd, regs[i].reg, p); } - r |= hv_vcpu_get_sys_reg(fd, HV_SYS_REG_MIDR_EL1, &acc->midr); r |= hv_vcpu_destroy(fd); /* From patchwork Tue Jan 3 18:16:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638753 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1393884pvb; Tue, 3 Jan 2023 10:26:53 -0800 (PST) X-Google-Smtp-Source: AMrXdXt4Ftez8pxJYRXX1AwKrvrAzFsv1b0jsQ9XmZBOAXAuZGO+bPORiv0VNIypeHvy88mez46U X-Received: by 2002:a05:622a:4c88:b0:3a8:21a5:d93 with SMTP id ez8-20020a05622a4c8800b003a821a50d93mr71981743qtb.39.1672770413172; Tue, 03 Jan 2023 10:26:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770413; cv=none; d=google.com; s=arc-20160816; b=H722VLHrpWdzsyFONSILt0w3ARZXlKHsVw38My9/XnavAmSWlFhH48leHkL7KQ/OeR VWmQVD0sbkPFudoKtshvooqq+Yd1gIMVTIQeGppVzrKWL36N6rOuX/P58CJA0bBvxSjp 11iakvbiwQ0o4ahqQEQgheCngRu5Kt6Ox/MpflZ+zzxPNFXDlWOUE7+osgdWjQtsJIWw w8h3ESG1PEXg+PIV3ZGwUCIoH7m1Fbjd2z3Of3AN3xqZ0aQlMY1VHszFV5oo436y3Krw G2mAZOoSSm3PT44mAKpYjhdoawU8KQjWbJR5AC4e1IWapktpwPgxErGIf6nHDXQTe2yV uelA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=UudCQe6aaBu/DssdkCisyt5+2IhUcMmaavH5MxGn6CU=; b=FXqRE5ePNarpwcA7vTMYmNarCUxrfbtMRfqV4HgWe/FrZXXsZnPlkL2/s9OlOjV/NT NT6LpRnNfOXgfYbTwc4R0/05v1f0qNloNk2oo2DCYRfcbpsH1zWdF+Dfys1sQEFz2JkM K8Qvxlr6gYL77V04t+1M1ZM5CmZYMgnp7prXRRNqJpOOfB5Po2sZgaUxAkJqgyOnQNtM M7bE8K8zNdbTaG/69YTm/kz1tUkXCIewkdjgIL0LkzBAYq7rJcWIbDv1LE9PG07+iia2 EbAmb8HDOD3CXxnxcd3Y/jS0vWsCweWNvdtrtsZ7Caq0/PyCVx1omiQBI3T6T64VmIlV CWBQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ECEPau6y; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id q47-20020a05620a2a6f00b006faebc4bfeasi16523279qkp.244.2023.01.03.10.26.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:26:53 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ECEPau6y; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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" -static void aarch64_a35_class_init(ARMCPUClass *cpu) +static void aarch64_a35_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = "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); /* From B2.2 AArch64 identification registers. */ - cpu->midr = 0x411fd040; - cpu->revidr = 0; - cpu->ctr = 0x84448004; - cpu->isar.id_pfr0 = 0x00000131; - cpu->isar.id_pfr1 = 0x00011011; - cpu->isar.id_dfr0 = 0x03010066; - cpu->id_afr0 = 0; - cpu->isar.id_mmfr0 = 0x10201105; - cpu->isar.id_mmfr1 = 0x40000000; - cpu->isar.id_mmfr2 = 0x01260000; - cpu->isar.id_mmfr3 = 0x02102211; - cpu->isar.id_isar0 = 0x02101110; - cpu->isar.id_isar1 = 0x13112111; - cpu->isar.id_isar2 = 0x21232042; - cpu->isar.id_isar3 = 0x01112131; - cpu->isar.id_isar4 = 0x00011142; - cpu->isar.id_isar5 = 0x00011121; - cpu->isar.id_aa64pfr0 = 0x00002222; - cpu->isar.id_aa64pfr1 = 0; - cpu->isar.id_aa64dfr0 = 0x10305106; - cpu->isar.id_aa64dfr1 = 0; - cpu->isar.id_aa64isar0 = 0x00011120; - cpu->isar.id_aa64isar1 = 0; - cpu->isar.id_aa64mmfr0 = 0x00101122; - cpu->isar.id_aa64mmfr1 = 0; - cpu->clidr = 0x0a200023; - cpu->dcz_blocksize = 4; + acc->midr = 0x411fd040; + acc->revidr = 0; + acc->ctr = 0x84448004; + acc->isar.id_pfr0 = 0x00000131; + acc->isar.id_pfr1 = 0x00011011; + acc->isar.id_dfr0 = 0x03010066; + acc->id_afr0 = 0; + acc->isar.id_mmfr0 = 0x10201105; + acc->isar.id_mmfr1 = 0x40000000; + acc->isar.id_mmfr2 = 0x01260000; + acc->isar.id_mmfr3 = 0x02102211; + acc->isar.id_isar0 = 0x02101110; + acc->isar.id_isar1 = 0x13112111; + acc->isar.id_isar2 = 0x21232042; + acc->isar.id_isar3 = 0x01112131; + acc->isar.id_isar4 = 0x00011142; + acc->isar.id_isar5 = 0x00011121; + acc->isar.id_aa64pfr0 = 0x00002222; + acc->isar.id_aa64pfr1 = 0; + acc->isar.id_aa64dfr0 = 0x10305106; + acc->isar.id_aa64dfr1 = 0; + acc->isar.id_aa64isar0 = 0x00011120; + acc->isar.id_aa64isar1 = 0; + acc->isar.id_aa64mmfr0 = 0x00101122; + acc->isar.id_aa64mmfr1 = 0; + acc->clidr = 0x0a200023; + acc->dcz_blocksize = 4; /* From B2.4 AArch64 Virtual Memory control registers */ - cpu->reset_sctlr = 0x00c50838; + acc->reset_sctlr = 0x00c50838; /* From B2.10 AArch64 performance monitor registers */ - cpu->isar.reset_pmcr_el0 = 0x410a3000; + acc->isar.reset_pmcr_el0 = 0x410a3000; /* From B2.29 Cache ID registers */ - cpu->ccsidr[0] = 0x700fe01a; /* 32KB L1 dcache */ - cpu->ccsidr[1] = 0x201fe00a; /* 32KB L1 icache */ - cpu->ccsidr[2] = 0x703fe03a; /* 512KB L2 cache */ + acc->ccsidr[0] = 0x700fe01a; /* 32KB L1 dcache */ + acc->ccsidr[1] = 0x201fe00a; /* 32KB L1 icache */ + acc->ccsidr[2] = 0x703fe03a; /* 512KB L2 cache */ /* From B3.5 VGIC Type register */ - cpu->gic_num_lrs = 4; - cpu->gic_vpribits = 5; - cpu->gic_vprebits = 5; - cpu->gic_pribits = 5; + acc->gic_num_lrs = 4; + acc->gic_vpribits = 5; + acc->gic_vprebits = 5; + acc->gic_pribits = 5; /* From C6.4 Debug ID Register */ - cpu->isar.dbgdidr = 0x3516d000; + acc->isar.dbgdidr = 0x3516d000; /* From C6.5 Debug Device ID Register */ - cpu->isar.dbgdevid = 0x00110f13; + acc->isar.dbgdevid = 0x00110f13; /* From C6.6 Debug Device ID Register 1 */ - cpu->isar.dbgdevid1 = 0x2; + acc->isar.dbgdevid1 = 0x2; /* From Cortex-A35 SIMD and Floating-point Support r1p0 */ /* From 3.2 AArch32 register summary */ - cpu->reset_fpsid = 0x41034043; + acc->reset_fpsid = 0x41034043; /* From 2.2 AArch64 register summary */ - cpu->isar.mvfr0 = 0x10110222; - cpu->isar.mvfr1 = 0x12111111; - cpu->isar.mvfr2 = 0x00000043; + acc->isar.mvfr0 = 0x10110222; + acc->isar.mvfr1 = 0x12111111; + acc->isar.mvfr2 = 0x00000043; /* 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); } void arm_cpu_sve_finalize(ARMCPU *cpu, Error **errp) @@ -676,338 +676,338 @@ void arm_cpu_lpa2_finalize(ARMCPU *cpu, Error **errp) cpu->isar.id_aa64mmfr0 = t; } -static void aarch64_a57_class_init(ARMCPUClass *cpu) +static void aarch64_a57_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = QEMU_KVM_ARM_TARGET_CORTEX_A57; - cpu->midr = 0x411fd070; - cpu->revidr = 0x00000000; - cpu->reset_fpsid = 0x41034070; - cpu->isar.mvfr0 = 0x10110222; - cpu->isar.mvfr1 = 0x12111111; - cpu->isar.mvfr2 = 0x00000043; - cpu->ctr = 0x8444c004; - cpu->reset_sctlr = 0x00c50838; - cpu->isar.id_pfr0 = 0x00000131; - cpu->isar.id_pfr1 = 0x00011011; - cpu->isar.id_dfr0 = 0x03010066; - cpu->id_afr0 = 0x00000000; - cpu->isar.id_mmfr0 = 0x10101105; - cpu->isar.id_mmfr1 = 0x40000000; - cpu->isar.id_mmfr2 = 0x01260000; - cpu->isar.id_mmfr3 = 0x02102211; - cpu->isar.id_isar0 = 0x02101110; - cpu->isar.id_isar1 = 0x13112111; - cpu->isar.id_isar2 = 0x21232042; - cpu->isar.id_isar3 = 0x01112131; - cpu->isar.id_isar4 = 0x00011142; - cpu->isar.id_isar5 = 0x00011121; - cpu->isar.id_isar6 = 0; - cpu->isar.id_aa64pfr0 = 0x00002222; - cpu->isar.id_aa64dfr0 = 0x10305106; - cpu->isar.id_aa64isar0 = 0x00011120; - cpu->isar.id_aa64mmfr0 = 0x00001124; - cpu->isar.dbgdidr = 0x3516d000; - cpu->isar.dbgdevid = 0x01110f13; - cpu->isar.dbgdevid1 = 0x2; - cpu->isar.reset_pmcr_el0 = 0x41013000; - cpu->clidr = 0x0a200023; - cpu->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */ - cpu->ccsidr[1] = 0x201fe012; /* 48KB L1 icache */ - cpu->ccsidr[2] = 0x70ffe07a; /* 2048KB L2 cache */ - cpu->dcz_blocksize = 4; /* 64 bytes */ - cpu->gic_num_lrs = 4; - cpu->gic_vpribits = 5; - cpu->gic_vprebits = 5; - cpu->gic_pribits = 5; - define_cortex_a72_a57_a53_cp_reginfo(cpu); + acc->dtb_compatible = "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 = QEMU_KVM_ARM_TARGET_CORTEX_A57; + acc->midr = 0x411fd070; + acc->revidr = 0x00000000; + acc->reset_fpsid = 0x41034070; + acc->isar.mvfr0 = 0x10110222; + acc->isar.mvfr1 = 0x12111111; + acc->isar.mvfr2 = 0x00000043; + acc->ctr = 0x8444c004; + acc->reset_sctlr = 0x00c50838; + acc->isar.id_pfr0 = 0x00000131; + acc->isar.id_pfr1 = 0x00011011; + acc->isar.id_dfr0 = 0x03010066; + acc->id_afr0 = 0x00000000; + acc->isar.id_mmfr0 = 0x10101105; + acc->isar.id_mmfr1 = 0x40000000; + acc->isar.id_mmfr2 = 0x01260000; + acc->isar.id_mmfr3 = 0x02102211; + acc->isar.id_isar0 = 0x02101110; + acc->isar.id_isar1 = 0x13112111; + acc->isar.id_isar2 = 0x21232042; + acc->isar.id_isar3 = 0x01112131; + acc->isar.id_isar4 = 0x00011142; + acc->isar.id_isar5 = 0x00011121; + acc->isar.id_isar6 = 0; + acc->isar.id_aa64pfr0 = 0x00002222; + acc->isar.id_aa64dfr0 = 0x10305106; + acc->isar.id_aa64isar0 = 0x00011120; + acc->isar.id_aa64mmfr0 = 0x00001124; + acc->isar.dbgdidr = 0x3516d000; + acc->isar.dbgdevid = 0x01110f13; + acc->isar.dbgdevid1 = 0x2; + acc->isar.reset_pmcr_el0 = 0x41013000; + acc->clidr = 0x0a200023; + acc->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */ + acc->ccsidr[1] = 0x201fe012; /* 48KB L1 icache */ + acc->ccsidr[2] = 0x70ffe07a; /* 2048KB L2 cache */ + acc->dcz_blocksize = 4; /* 64 bytes */ + acc->gic_num_lrs = 4; + acc->gic_vpribits = 5; + acc->gic_vprebits = 5; + acc->gic_pribits = 5; + define_cortex_a72_a57_a53_cp_reginfo(acc); } -static void aarch64_a53_class_init(ARMCPUClass *cpu) +static void aarch64_a53_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = QEMU_KVM_ARM_TARGET_CORTEX_A53; - cpu->midr = 0x410fd034; - cpu->revidr = 0x00000000; - cpu->reset_fpsid = 0x41034070; - cpu->isar.mvfr0 = 0x10110222; - cpu->isar.mvfr1 = 0x12111111; - cpu->isar.mvfr2 = 0x00000043; - cpu->ctr = 0x84448004; /* L1Ip = VIPT */ - cpu->reset_sctlr = 0x00c50838; - cpu->isar.id_pfr0 = 0x00000131; - cpu->isar.id_pfr1 = 0x00011011; - cpu->isar.id_dfr0 = 0x03010066; - cpu->id_afr0 = 0x00000000; - cpu->isar.id_mmfr0 = 0x10101105; - cpu->isar.id_mmfr1 = 0x40000000; - cpu->isar.id_mmfr2 = 0x01260000; - cpu->isar.id_mmfr3 = 0x02102211; - cpu->isar.id_isar0 = 0x02101110; - cpu->isar.id_isar1 = 0x13112111; - cpu->isar.id_isar2 = 0x21232042; - cpu->isar.id_isar3 = 0x01112131; - cpu->isar.id_isar4 = 0x00011142; - cpu->isar.id_isar5 = 0x00011121; - cpu->isar.id_isar6 = 0; - cpu->isar.id_aa64pfr0 = 0x00002222; - cpu->isar.id_aa64dfr0 = 0x10305106; - cpu->isar.id_aa64isar0 = 0x00011120; - cpu->isar.id_aa64mmfr0 = 0x00001122; /* 40 bit physical addr */ - cpu->isar.dbgdidr = 0x3516d000; - cpu->isar.dbgdevid = 0x00110f13; - cpu->isar.dbgdevid1 = 0x1; - cpu->isar.reset_pmcr_el0 = 0x41033000; - cpu->clidr = 0x0a200023; - cpu->ccsidr[0] = 0x700fe01a; /* 32KB L1 dcache */ - cpu->ccsidr[1] = 0x201fe00a; /* 32KB L1 icache */ - cpu->ccsidr[2] = 0x707fe07a; /* 1024KB L2 cache */ - cpu->dcz_blocksize = 4; /* 64 bytes */ - cpu->gic_num_lrs = 4; - cpu->gic_vpribits = 5; - cpu->gic_vprebits = 5; - cpu->gic_pribits = 5; - define_cortex_a72_a57_a53_cp_reginfo(cpu); + acc->dtb_compatible = "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 = QEMU_KVM_ARM_TARGET_CORTEX_A53; + acc->midr = 0x410fd034; + acc->revidr = 0x00000000; + acc->reset_fpsid = 0x41034070; + acc->isar.mvfr0 = 0x10110222; + acc->isar.mvfr1 = 0x12111111; + acc->isar.mvfr2 = 0x00000043; + acc->ctr = 0x84448004; /* L1Ip = VIPT */ + acc->reset_sctlr = 0x00c50838; + acc->isar.id_pfr0 = 0x00000131; + acc->isar.id_pfr1 = 0x00011011; + acc->isar.id_dfr0 = 0x03010066; + acc->id_afr0 = 0x00000000; + acc->isar.id_mmfr0 = 0x10101105; + acc->isar.id_mmfr1 = 0x40000000; + acc->isar.id_mmfr2 = 0x01260000; + acc->isar.id_mmfr3 = 0x02102211; + acc->isar.id_isar0 = 0x02101110; + acc->isar.id_isar1 = 0x13112111; + acc->isar.id_isar2 = 0x21232042; + acc->isar.id_isar3 = 0x01112131; + acc->isar.id_isar4 = 0x00011142; + acc->isar.id_isar5 = 0x00011121; + acc->isar.id_isar6 = 0; + acc->isar.id_aa64pfr0 = 0x00002222; + acc->isar.id_aa64dfr0 = 0x10305106; + acc->isar.id_aa64isar0 = 0x00011120; + acc->isar.id_aa64mmfr0 = 0x00001122; /* 40 bit physical addr */ + acc->isar.dbgdidr = 0x3516d000; + acc->isar.dbgdevid = 0x00110f13; + acc->isar.dbgdevid1 = 0x1; + acc->isar.reset_pmcr_el0 = 0x41033000; + acc->clidr = 0x0a200023; + acc->ccsidr[0] = 0x700fe01a; /* 32KB L1 dcache */ + acc->ccsidr[1] = 0x201fe00a; /* 32KB L1 icache */ + acc->ccsidr[2] = 0x707fe07a; /* 1024KB L2 cache */ + acc->dcz_blocksize = 4; /* 64 bytes */ + acc->gic_num_lrs = 4; + acc->gic_vpribits = 5; + acc->gic_vprebits = 5; + acc->gic_pribits = 5; + define_cortex_a72_a57_a53_cp_reginfo(acc); } -static void aarch64_a55_class_init(ARMCPUClass *cpu) +static void aarch64_a55_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = "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); /* Ordered by B2.4 AArch64 registers by functional group */ - cpu->clidr = 0x82000023; - cpu->ctr = 0x84448004; /* L1Ip = VIPT */ - cpu->dcz_blocksize = 4; /* 64 bytes */ - cpu->isar.id_aa64dfr0 = 0x0000000010305408ull; - cpu->isar.id_aa64isar0 = 0x0000100010211120ull; - cpu->isar.id_aa64isar1 = 0x0000000000100001ull; - cpu->isar.id_aa64mmfr0 = 0x0000000000101122ull; - cpu->isar.id_aa64mmfr1 = 0x0000000010212122ull; - cpu->isar.id_aa64mmfr2 = 0x0000000000001011ull; - cpu->isar.id_aa64pfr0 = 0x0000000010112222ull; - cpu->isar.id_aa64pfr1 = 0x0000000000000010ull; - cpu->id_afr0 = 0x00000000; - cpu->isar.id_dfr0 = 0x04010088; - cpu->isar.id_isar0 = 0x02101110; - cpu->isar.id_isar1 = 0x13112111; - cpu->isar.id_isar2 = 0x21232042; - cpu->isar.id_isar3 = 0x01112131; - cpu->isar.id_isar4 = 0x00011142; - cpu->isar.id_isar5 = 0x01011121; - cpu->isar.id_isar6 = 0x00000010; - cpu->isar.id_mmfr0 = 0x10201105; - cpu->isar.id_mmfr1 = 0x40000000; - cpu->isar.id_mmfr2 = 0x01260000; - cpu->isar.id_mmfr3 = 0x02122211; - cpu->isar.id_mmfr4 = 0x00021110; - cpu->isar.id_pfr0 = 0x10010131; - cpu->isar.id_pfr1 = 0x00011011; - cpu->isar.id_pfr2 = 0x00000011; - cpu->midr = 0x412FD050; /* r2p0 */ - cpu->revidr = 0; + acc->clidr = 0x82000023; + acc->ctr = 0x84448004; /* L1Ip = VIPT */ + acc->dcz_blocksize = 4; /* 64 bytes */ + acc->isar.id_aa64dfr0 = 0x0000000010305408ull; + acc->isar.id_aa64isar0 = 0x0000100010211120ull; + acc->isar.id_aa64isar1 = 0x0000000000100001ull; + acc->isar.id_aa64mmfr0 = 0x0000000000101122ull; + acc->isar.id_aa64mmfr1 = 0x0000000010212122ull; + acc->isar.id_aa64mmfr2 = 0x0000000000001011ull; + acc->isar.id_aa64pfr0 = 0x0000000010112222ull; + acc->isar.id_aa64pfr1 = 0x0000000000000010ull; + acc->id_afr0 = 0x00000000; + acc->isar.id_dfr0 = 0x04010088; + acc->isar.id_isar0 = 0x02101110; + acc->isar.id_isar1 = 0x13112111; + acc->isar.id_isar2 = 0x21232042; + acc->isar.id_isar3 = 0x01112131; + acc->isar.id_isar4 = 0x00011142; + acc->isar.id_isar5 = 0x01011121; + acc->isar.id_isar6 = 0x00000010; + acc->isar.id_mmfr0 = 0x10201105; + acc->isar.id_mmfr1 = 0x40000000; + acc->isar.id_mmfr2 = 0x01260000; + acc->isar.id_mmfr3 = 0x02122211; + acc->isar.id_mmfr4 = 0x00021110; + acc->isar.id_pfr0 = 0x10010131; + acc->isar.id_pfr1 = 0x00011011; + acc->isar.id_pfr2 = 0x00000011; + acc->midr = 0x412FD050; /* r2p0 */ + acc->revidr = 0; /* From B2.23 CCSIDR_EL1 */ - cpu->ccsidr[0] = 0x700fe01a; /* 32KB L1 dcache */ - cpu->ccsidr[1] = 0x200fe01a; /* 32KB L1 icache */ - cpu->ccsidr[2] = 0x703fe07a; /* 512KB L2 cache */ + acc->ccsidr[0] = 0x700fe01a; /* 32KB L1 dcache */ + acc->ccsidr[1] = 0x200fe01a; /* 32KB L1 icache */ + acc->ccsidr[2] = 0x703fe07a; /* 512KB L2 cache */ /* From B2.96 SCTLR_EL3 */ - cpu->reset_sctlr = 0x30c50838; + acc->reset_sctlr = 0x30c50838; /* From B4.45 ICH_VTR_EL2 */ - cpu->gic_num_lrs = 4; - cpu->gic_vpribits = 5; - cpu->gic_vprebits = 5; - cpu->gic_pribits = 5; + acc->gic_num_lrs = 4; + acc->gic_vpribits = 5; + acc->gic_vprebits = 5; + acc->gic_pribits = 5; - cpu->isar.mvfr0 = 0x10110222; - cpu->isar.mvfr1 = 0x13211111; - cpu->isar.mvfr2 = 0x00000043; + acc->isar.mvfr0 = 0x10110222; + acc->isar.mvfr1 = 0x13211111; + acc->isar.mvfr2 = 0x00000043; /* From D5.4 AArch64 PMU register summary */ - cpu->isar.reset_pmcr_el0 = 0x410b3000; + acc->isar.reset_pmcr_el0 = 0x410b3000; } -static void aarch64_a72_class_init(ARMCPUClass *cpu) +static void aarch64_a72_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = 0x410fd083; - cpu->revidr = 0x00000000; - cpu->reset_fpsid = 0x41034080; - cpu->isar.mvfr0 = 0x10110222; - cpu->isar.mvfr1 = 0x12111111; - cpu->isar.mvfr2 = 0x00000043; - cpu->ctr = 0x8444c004; - cpu->reset_sctlr = 0x00c50838; - cpu->isar.id_pfr0 = 0x00000131; - cpu->isar.id_pfr1 = 0x00011011; - cpu->isar.id_dfr0 = 0x03010066; - cpu->id_afr0 = 0x00000000; - cpu->isar.id_mmfr0 = 0x10201105; - cpu->isar.id_mmfr1 = 0x40000000; - cpu->isar.id_mmfr2 = 0x01260000; - cpu->isar.id_mmfr3 = 0x02102211; - cpu->isar.id_isar0 = 0x02101110; - cpu->isar.id_isar1 = 0x13112111; - cpu->isar.id_isar2 = 0x21232042; - cpu->isar.id_isar3 = 0x01112131; - cpu->isar.id_isar4 = 0x00011142; - cpu->isar.id_isar5 = 0x00011121; - cpu->isar.id_aa64pfr0 = 0x00002222; - cpu->isar.id_aa64dfr0 = 0x10305106; - cpu->isar.id_aa64isar0 = 0x00011120; - cpu->isar.id_aa64mmfr0 = 0x00001124; - cpu->isar.dbgdidr = 0x3516d000; - cpu->isar.dbgdevid = 0x01110f13; - cpu->isar.dbgdevid1 = 0x2; - cpu->isar.reset_pmcr_el0 = 0x41023000; - cpu->clidr = 0x0a200023; - cpu->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */ - cpu->ccsidr[1] = 0x201fe012; /* 48KB L1 icache */ - cpu->ccsidr[2] = 0x707fe07a; /* 1MB L2 cache */ - cpu->dcz_blocksize = 4; /* 64 bytes */ - cpu->gic_num_lrs = 4; - cpu->gic_vpribits = 5; - cpu->gic_vprebits = 5; - cpu->gic_pribits = 5; - define_cortex_a72_a57_a53_cp_reginfo(cpu); + acc->dtb_compatible = "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 = 0x410fd083; + acc->revidr = 0x00000000; + acc->reset_fpsid = 0x41034080; + acc->isar.mvfr0 = 0x10110222; + acc->isar.mvfr1 = 0x12111111; + acc->isar.mvfr2 = 0x00000043; + acc->ctr = 0x8444c004; + acc->reset_sctlr = 0x00c50838; + acc->isar.id_pfr0 = 0x00000131; + acc->isar.id_pfr1 = 0x00011011; + acc->isar.id_dfr0 = 0x03010066; + acc->id_afr0 = 0x00000000; + acc->isar.id_mmfr0 = 0x10201105; + acc->isar.id_mmfr1 = 0x40000000; + acc->isar.id_mmfr2 = 0x01260000; + acc->isar.id_mmfr3 = 0x02102211; + acc->isar.id_isar0 = 0x02101110; + acc->isar.id_isar1 = 0x13112111; + acc->isar.id_isar2 = 0x21232042; + acc->isar.id_isar3 = 0x01112131; + acc->isar.id_isar4 = 0x00011142; + acc->isar.id_isar5 = 0x00011121; + acc->isar.id_aa64pfr0 = 0x00002222; + acc->isar.id_aa64dfr0 = 0x10305106; + acc->isar.id_aa64isar0 = 0x00011120; + acc->isar.id_aa64mmfr0 = 0x00001124; + acc->isar.dbgdidr = 0x3516d000; + acc->isar.dbgdevid = 0x01110f13; + acc->isar.dbgdevid1 = 0x2; + acc->isar.reset_pmcr_el0 = 0x41023000; + acc->clidr = 0x0a200023; + acc->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */ + acc->ccsidr[1] = 0x201fe012; /* 48KB L1 icache */ + acc->ccsidr[2] = 0x707fe07a; /* 1MB L2 cache */ + acc->dcz_blocksize = 4; /* 64 bytes */ + acc->gic_num_lrs = 4; + acc->gic_vpribits = 5; + acc->gic_vprebits = 5; + acc->gic_pribits = 5; + define_cortex_a72_a57_a53_cp_reginfo(acc); } -static void aarch64_a76_class_init(ARMCPUClass *cpu) +static void aarch64_a76_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = "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); /* Ordered by B2.4 AArch64 registers by functional group */ - cpu->clidr = 0x82000023; - cpu->ctr = 0x8444C004; - cpu->dcz_blocksize = 4; - cpu->isar.id_aa64dfr0 = 0x0000000010305408ull; - cpu->isar.id_aa64isar0 = 0x0000100010211120ull; - cpu->isar.id_aa64isar1 = 0x0000000000100001ull; - cpu->isar.id_aa64mmfr0 = 0x0000000000101122ull; - cpu->isar.id_aa64mmfr1 = 0x0000000010212122ull; - cpu->isar.id_aa64mmfr2 = 0x0000000000001011ull; - cpu->isar.id_aa64pfr0 = 0x1100000010111112ull; /* GIC filled in later */ - cpu->isar.id_aa64pfr1 = 0x0000000000000010ull; - cpu->id_afr0 = 0x00000000; - cpu->isar.id_dfr0 = 0x04010088; - cpu->isar.id_isar0 = 0x02101110; - cpu->isar.id_isar1 = 0x13112111; - cpu->isar.id_isar2 = 0x21232042; - cpu->isar.id_isar3 = 0x01112131; - cpu->isar.id_isar4 = 0x00010142; - cpu->isar.id_isar5 = 0x01011121; - cpu->isar.id_isar6 = 0x00000010; - cpu->isar.id_mmfr0 = 0x10201105; - cpu->isar.id_mmfr1 = 0x40000000; - cpu->isar.id_mmfr2 = 0x01260000; - cpu->isar.id_mmfr3 = 0x02122211; - cpu->isar.id_mmfr4 = 0x00021110; - cpu->isar.id_pfr0 = 0x10010131; - cpu->isar.id_pfr1 = 0x00010000; /* GIC filled in later */ - cpu->isar.id_pfr2 = 0x00000011; - cpu->midr = 0x414fd0b1; /* r4p1 */ - cpu->revidr = 0; + acc->clidr = 0x82000023; + acc->ctr = 0x8444C004; + acc->dcz_blocksize = 4; + acc->isar.id_aa64dfr0 = 0x0000000010305408ull; + acc->isar.id_aa64isar0 = 0x0000100010211120ull; + acc->isar.id_aa64isar1 = 0x0000000000100001ull; + acc->isar.id_aa64mmfr0 = 0x0000000000101122ull; + acc->isar.id_aa64mmfr1 = 0x0000000010212122ull; + acc->isar.id_aa64mmfr2 = 0x0000000000001011ull; + acc->isar.id_aa64pfr0 = 0x1100000010111112ull; /* GIC filled in later */ + acc->isar.id_aa64pfr1 = 0x0000000000000010ull; + acc->id_afr0 = 0x00000000; + acc->isar.id_dfr0 = 0x04010088; + acc->isar.id_isar0 = 0x02101110; + acc->isar.id_isar1 = 0x13112111; + acc->isar.id_isar2 = 0x21232042; + acc->isar.id_isar3 = 0x01112131; + acc->isar.id_isar4 = 0x00010142; + acc->isar.id_isar5 = 0x01011121; + acc->isar.id_isar6 = 0x00000010; + acc->isar.id_mmfr0 = 0x10201105; + acc->isar.id_mmfr1 = 0x40000000; + acc->isar.id_mmfr2 = 0x01260000; + acc->isar.id_mmfr3 = 0x02122211; + acc->isar.id_mmfr4 = 0x00021110; + acc->isar.id_pfr0 = 0x10010131; + acc->isar.id_pfr1 = 0x00010000; /* GIC filled in later */ + acc->isar.id_pfr2 = 0x00000011; + acc->midr = 0x414fd0b1; /* r4p1 */ + acc->revidr = 0; /* From B2.18 CCSIDR_EL1 */ - cpu->ccsidr[0] = 0x701fe01a; /* 64KB L1 dcache */ - cpu->ccsidr[1] = 0x201fe01a; /* 64KB L1 icache */ - cpu->ccsidr[2] = 0x707fe03a; /* 512KB L2 cache */ + acc->ccsidr[0] = 0x701fe01a; /* 64KB L1 dcache */ + acc->ccsidr[1] = 0x201fe01a; /* 64KB L1 icache */ + acc->ccsidr[2] = 0x707fe03a; /* 512KB L2 cache */ /* From B2.93 SCTLR_EL3 */ - cpu->reset_sctlr = 0x30c50838; + acc->reset_sctlr = 0x30c50838; /* From B4.23 ICH_VTR_EL2 */ - cpu->gic_num_lrs = 4; - cpu->gic_vpribits = 5; - cpu->gic_vprebits = 5; - cpu->gic_pribits = 5; + acc->gic_num_lrs = 4; + acc->gic_vpribits = 5; + acc->gic_vprebits = 5; + acc->gic_pribits = 5; /* From B5.1 AdvSIMD AArch64 register summary */ - cpu->isar.mvfr0 = 0x10110222; - cpu->isar.mvfr1 = 0x13211111; - cpu->isar.mvfr2 = 0x00000043; + acc->isar.mvfr0 = 0x10110222; + acc->isar.mvfr1 = 0x13211111; + acc->isar.mvfr2 = 0x00000043; /* From D5.1 AArch64 PMU register summary */ - cpu->isar.reset_pmcr_el0 = 0x410b3000; + acc->isar.reset_pmcr_el0 = 0x410b3000; } -static void aarch64_a64fx_class_init(ARMCPUClass *cpu) +static void aarch64_a64fx_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = 0x461f0010; - cpu->revidr = 0x00000000; - cpu->ctr = 0x86668006; - cpu->reset_sctlr = 0x30000180; - cpu->isar.id_aa64pfr0 = 0x0000000101111111; /* No RAS Extensions */ - cpu->isar.id_aa64pfr1 = 0x0000000000000000; - cpu->isar.id_aa64dfr0 = 0x0000000010305408; - cpu->isar.id_aa64dfr1 = 0x0000000000000000; - cpu->id_aa64afr0 = 0x0000000000000000; - cpu->id_aa64afr1 = 0x0000000000000000; - cpu->isar.id_aa64mmfr0 = 0x0000000000001122; - cpu->isar.id_aa64mmfr1 = 0x0000000011212100; - cpu->isar.id_aa64mmfr2 = 0x0000000000001011; - cpu->isar.id_aa64isar0 = 0x0000000010211120; - cpu->isar.id_aa64isar1 = 0x0000000000010001; - cpu->isar.id_aa64zfr0 = 0x0000000000000000; - cpu->clidr = 0x0000000080000023; - cpu->ccsidr[0] = 0x7007e01c; /* 64KB L1 dcache */ - cpu->ccsidr[1] = 0x2007e01c; /* 64KB L1 icache */ - cpu->ccsidr[2] = 0x70ffe07c; /* 8MB L2 cache */ - cpu->dcz_blocksize = 6; /* 256 bytes */ - cpu->gic_num_lrs = 4; - cpu->gic_vpribits = 5; - cpu->gic_vprebits = 5; - cpu->gic_pribits = 5; - cpu->isar.reset_pmcr_el0 = 0x46014040; + acc->dtb_compatible = "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 = 0x461f0010; + acc->revidr = 0x00000000; + acc->ctr = 0x86668006; + acc->reset_sctlr = 0x30000180; + acc->isar.id_aa64pfr0 = 0x0000000101111111; /* No RAS Extensions */ + acc->isar.id_aa64pfr1 = 0x0000000000000000; + acc->isar.id_aa64dfr0 = 0x0000000010305408; + acc->isar.id_aa64dfr1 = 0x0000000000000000; + acc->id_aa64afr0 = 0x0000000000000000; + acc->id_aa64afr1 = 0x0000000000000000; + acc->isar.id_aa64mmfr0 = 0x0000000000001122; + acc->isar.id_aa64mmfr1 = 0x0000000011212100; + acc->isar.id_aa64mmfr2 = 0x0000000000001011; + acc->isar.id_aa64isar0 = 0x0000000010211120; + acc->isar.id_aa64isar1 = 0x0000000000010001; + acc->isar.id_aa64zfr0 = 0x0000000000000000; + acc->clidr = 0x0000000080000023; + acc->ccsidr[0] = 0x7007e01c; /* 64KB L1 dcache */ + acc->ccsidr[1] = 0x2007e01c; /* 64KB L1 icache */ + acc->ccsidr[2] = 0x70ffe07c; /* 8MB L2 cache */ + acc->dcz_blocksize = 6; /* 256 bytes */ + acc->gic_num_lrs = 4; + acc->gic_vpribits = 5; + acc->gic_vprebits = 5; + acc->gic_pribits = 5; + acc->isar.reset_pmcr_el0 = 0x46014040; /* TODO: Add A64FX specific HPC extension registers */ } @@ -1023,71 +1023,71 @@ static void aarch64_a64fx_object_init(Object *obj) | (1 << 3); /* 512bit */ } -static void aarch64_neoverse_n1_class_init(ARMCPUClass *cpu) +static void aarch64_neoverse_n1_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = "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); /* Ordered by B2.4 AArch64 registers by functional group */ - cpu->clidr = 0x82000023; - cpu->ctr = 0x8444c004; - cpu->dcz_blocksize = 4; - cpu->isar.id_aa64dfr0 = 0x0000000110305408ull; - cpu->isar.id_aa64isar0 = 0x0000100010211120ull; - cpu->isar.id_aa64isar1 = 0x0000000000100001ull; - cpu->isar.id_aa64mmfr0 = 0x0000000000101125ull; - cpu->isar.id_aa64mmfr1 = 0x0000000010212122ull; - cpu->isar.id_aa64mmfr2 = 0x0000000000001011ull; - cpu->isar.id_aa64pfr0 = 0x1100000010111112ull; /* GIC filled in later */ - cpu->isar.id_aa64pfr1 = 0x0000000000000020ull; - cpu->id_afr0 = 0x00000000; - cpu->isar.id_dfr0 = 0x04010088; - cpu->isar.id_isar0 = 0x02101110; - cpu->isar.id_isar1 = 0x13112111; - cpu->isar.id_isar2 = 0x21232042; - cpu->isar.id_isar3 = 0x01112131; - cpu->isar.id_isar4 = 0x00010142; - cpu->isar.id_isar5 = 0x01011121; - cpu->isar.id_isar6 = 0x00000010; - cpu->isar.id_mmfr0 = 0x10201105; - cpu->isar.id_mmfr1 = 0x40000000; - cpu->isar.id_mmfr2 = 0x01260000; - cpu->isar.id_mmfr3 = 0x02122211; - cpu->isar.id_mmfr4 = 0x00021110; - cpu->isar.id_pfr0 = 0x10010131; - cpu->isar.id_pfr1 = 0x00010000; /* GIC filled in later */ - cpu->isar.id_pfr2 = 0x00000011; - cpu->midr = 0x414fd0c1; /* r4p1 */ - cpu->revidr = 0; + acc->clidr = 0x82000023; + acc->ctr = 0x8444c004; + acc->dcz_blocksize = 4; + acc->isar.id_aa64dfr0 = 0x0000000110305408ull; + acc->isar.id_aa64isar0 = 0x0000100010211120ull; + acc->isar.id_aa64isar1 = 0x0000000000100001ull; + acc->isar.id_aa64mmfr0 = 0x0000000000101125ull; + acc->isar.id_aa64mmfr1 = 0x0000000010212122ull; + acc->isar.id_aa64mmfr2 = 0x0000000000001011ull; + acc->isar.id_aa64pfr0 = 0x1100000010111112ull; /* GIC filled in later */ + acc->isar.id_aa64pfr1 = 0x0000000000000020ull; + acc->id_afr0 = 0x00000000; + acc->isar.id_dfr0 = 0x04010088; + acc->isar.id_isar0 = 0x02101110; + acc->isar.id_isar1 = 0x13112111; + acc->isar.id_isar2 = 0x21232042; + acc->isar.id_isar3 = 0x01112131; + acc->isar.id_isar4 = 0x00010142; + acc->isar.id_isar5 = 0x01011121; + acc->isar.id_isar6 = 0x00000010; + acc->isar.id_mmfr0 = 0x10201105; + acc->isar.id_mmfr1 = 0x40000000; + acc->isar.id_mmfr2 = 0x01260000; + acc->isar.id_mmfr3 = 0x02122211; + acc->isar.id_mmfr4 = 0x00021110; + acc->isar.id_pfr0 = 0x10010131; + acc->isar.id_pfr1 = 0x00010000; /* GIC filled in later */ + acc->isar.id_pfr2 = 0x00000011; + acc->midr = 0x414fd0c1; /* r4p1 */ + acc->revidr = 0; /* From B2.23 CCSIDR_EL1 */ - cpu->ccsidr[0] = 0x701fe01a; /* 64KB L1 dcache */ - cpu->ccsidr[1] = 0x201fe01a; /* 64KB L1 icache */ - cpu->ccsidr[2] = 0x70ffe03a; /* 1MB L2 cache */ + acc->ccsidr[0] = 0x701fe01a; /* 64KB L1 dcache */ + acc->ccsidr[1] = 0x201fe01a; /* 64KB L1 icache */ + acc->ccsidr[2] = 0x70ffe03a; /* 1MB L2 cache */ /* From B2.98 SCTLR_EL3 */ - cpu->reset_sctlr = 0x30c50838; + acc->reset_sctlr = 0x30c50838; /* From B4.23 ICH_VTR_EL2 */ - cpu->gic_num_lrs = 4; - cpu->gic_vpribits = 5; - cpu->gic_vprebits = 5; - cpu->gic_pribits = 5; + acc->gic_num_lrs = 4; + acc->gic_vpribits = 5; + acc->gic_vprebits = 5; + acc->gic_pribits = 5; /* From B5.1 AdvSIMD AArch64 register summary */ - cpu->isar.mvfr0 = 0x10110222; - cpu->isar.mvfr1 = 0x13211111; - cpu->isar.mvfr2 = 0x00000043; + acc->isar.mvfr0 = 0x10110222; + acc->isar.mvfr1 = 0x13211111; + acc->isar.mvfr2 = 0x00000043; /* From D5.1 AArch64 PMU register summary */ - cpu->isar.reset_pmcr_el0 = 0x410c3000; + acc->isar.reset_pmcr_el0 = 0x410c3000; } 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; 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); } /* * '-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 = "arm,arm-v8"; + aarch64_a57_class_init(acc); + acc->dtb_compatible = "arm,arm-v8"; /* * Reset MIDR so the guest doesn't mistake our 'max' CPU type for a real @@ -1170,18 +1170,18 @@ static bool aarch64_max_class_late_init(ARMCPUClass *cpu, Error **errp) t = FIELD_DP64(t, MIDR_EL1, PARTNUM, 'Q'); t = FIELD_DP64(t, MIDR_EL1, VARIANT, 0); t = FIELD_DP64(t, MIDR_EL1, REVISION, 0); - cpu->midr = t; + acc->midr = t; /* * We're going to set FEAT_S2FWB, which mandates that CLIDR_EL1.{LoUU,LoUIS} * are zero. */ - u = cpu->clidr; + u = acc->clidr; u = FIELD_DP32(u, CLIDR_EL1, LOUIS, 0); u = FIELD_DP32(u, CLIDR_EL1, LOUU, 0); - cpu->clidr = u; + acc->clidr = u; - t = cpu->isar.id_aa64isar0; + t = acc->isar.id_aa64isar0; t = FIELD_DP64(t, ID_AA64ISAR0, AES, 2); /* FEAT_PMULL */ t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 1); /* FEAT_SHA1 */ t = 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 = FIELD_DP64(t, ID_AA64ISAR0, TS, 2); /* FEAT_FlagM2 */ t = FIELD_DP64(t, ID_AA64ISAR0, TLB, 2); /* FEAT_TLBIRANGE */ t = FIELD_DP64(t, ID_AA64ISAR0, RNDR, 1); /* FEAT_RNG */ - cpu->isar.id_aa64isar0 = t; + acc->isar.id_aa64isar0 = t; - t = cpu->isar.id_aa64isar1; + t = acc->isar.id_aa64isar1; t = FIELD_DP64(t, ID_AA64ISAR1, DPB, 2); /* FEAT_DPB2 */ t = FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 1); /* FEAT_JSCVT */ t = 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 = FIELD_DP64(t, ID_AA64ISAR1, BF16, 1); /* FEAT_BF16 */ t = FIELD_DP64(t, ID_AA64ISAR1, DGH, 1); /* FEAT_DGH */ t = FIELD_DP64(t, ID_AA64ISAR1, I8MM, 1); /* FEAT_I8MM */ - cpu->isar.id_aa64isar1 = t; + acc->isar.id_aa64isar1 = t; - t = cpu->isar.id_aa64pfr0; + t = acc->isar.id_aa64pfr0; t = FIELD_DP64(t, ID_AA64PFR0, FP, 1); /* FEAT_FP16 */ t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 1); /* FEAT_FP16 */ t = 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 = FIELD_DP64(t, ID_AA64PFR0, DIT, 1); /* FEAT_DIT */ t = FIELD_DP64(t, ID_AA64PFR0, CSV2, 2); /* FEAT_CSV2_2 */ t = FIELD_DP64(t, ID_AA64PFR0, CSV3, 1); /* FEAT_CSV3 */ - cpu->isar.id_aa64pfr0 = t; + acc->isar.id_aa64pfr0 = t; - t = cpu->isar.id_aa64pfr1; + t = acc->isar.id_aa64pfr1; t = FIELD_DP64(t, ID_AA64PFR1, BT, 1); /* FEAT_BTI */ t = 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 = FIELD_DP64(t, ID_AA64PFR1, RAS_FRAC, 0); /* FEAT_RASv1p1 + FEAT_DoubleFault */ t = FIELD_DP64(t, ID_AA64PFR1, SME, 1); /* FEAT_SME */ t = FIELD_DP64(t, ID_AA64PFR1, CSV2_FRAC, 0); /* FEAT_CSV2_2 */ - cpu->isar.id_aa64pfr1 = t; + acc->isar.id_aa64pfr1 = t; - t = cpu->isar.id_aa64mmfr0; + t = acc->isar.id_aa64mmfr0; t = FIELD_DP64(t, ID_AA64MMFR0, PARANGE, 6); /* FEAT_LPA: 52 bits */ t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN16, 1); /* 16k pages supported */ t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN16_2, 2); /* 16k stage2 supported */ t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN64_2, 2); /* 64k stage2 supported */ t = FIELD_DP64(t, ID_AA64MMFR0, TGRAN4_2, 2); /* 4k stage2 supported */ - cpu->isar.id_aa64mmfr0 = t; + acc->isar.id_aa64mmfr0 = t; - t = cpu->isar.id_aa64mmfr1; + t = acc->isar.id_aa64mmfr1; t = FIELD_DP64(t, ID_AA64MMFR1, HAFDBS, 2); /* FEAT_HAFDBS */ t = FIELD_DP64(t, ID_AA64MMFR1, VMIDBITS, 2); /* FEAT_VMID16 */ t = 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 = FIELD_DP64(t, ID_AA64MMFR1, XNX, 1); /* FEAT_XNX */ t = FIELD_DP64(t, ID_AA64MMFR1, ETS, 1); /* FEAT_ETS */ t = FIELD_DP64(t, ID_AA64MMFR1, HCX, 1); /* FEAT_HCX */ - cpu->isar.id_aa64mmfr1 = t; + acc->isar.id_aa64mmfr1 = t; - t = cpu->isar.id_aa64mmfr2; + t = acc->isar.id_aa64mmfr2; t = FIELD_DP64(t, ID_AA64MMFR2, CNP, 1); /* FEAT_TTCNP */ t = FIELD_DP64(t, ID_AA64MMFR2, UAO, 1); /* FEAT_UAO */ t = 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 = FIELD_DP64(t, ID_AA64MMFR2, BBM, 2); /* FEAT_BBM at level 2 */ t = FIELD_DP64(t, ID_AA64MMFR2, EVT, 2); /* FEAT_EVT */ t = FIELD_DP64(t, ID_AA64MMFR2, E0PD, 1); /* FEAT_E0PD */ - cpu->isar.id_aa64mmfr2 = t; + acc->isar.id_aa64mmfr2 = t; - t = cpu->isar.id_aa64zfr0; + t = acc->isar.id_aa64zfr0; t = FIELD_DP64(t, ID_AA64ZFR0, SVEVER, 1); t = FIELD_DP64(t, ID_AA64ZFR0, AES, 2); /* FEAT_SVE_PMULL128 */ t = 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 = FIELD_DP64(t, ID_AA64ZFR0, I8MM, 1); /* FEAT_I8MM */ t = FIELD_DP64(t, ID_AA64ZFR0, F32MM, 1); /* FEAT_F32MM */ t = FIELD_DP64(t, ID_AA64ZFR0, F64MM, 1); /* FEAT_F64MM */ - cpu->isar.id_aa64zfr0 = t; + acc->isar.id_aa64zfr0 = t; - t = cpu->isar.id_aa64dfr0; + t = acc->isar.id_aa64dfr0; t = FIELD_DP64(t, ID_AA64DFR0, DEBUGVER, 9); /* FEAT_Debugv8p4 */ t = FIELD_DP64(t, ID_AA64DFR0, PMUVER, 6); /* FEAT_PMUv3p5 */ - cpu->isar.id_aa64dfr0 = t; + acc->isar.id_aa64dfr0 = t; - t = cpu->isar.id_aa64smfr0; + t = acc->isar.id_aa64smfr0; t = FIELD_DP64(t, ID_AA64SMFR0, F32F32, 1); /* FEAT_SME */ t = FIELD_DP64(t, ID_AA64SMFR0, B16F32, 1); /* FEAT_SME */ t = 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 = FIELD_DP64(t, ID_AA64SMFR0, F64F64, 1); /* FEAT_SME_F64F64 */ t = FIELD_DP64(t, ID_AA64SMFR0, I16I64, 0xf); /* FEAT_SME_I16I64 */ t = FIELD_DP64(t, ID_AA64SMFR0, FA64, 1); /* FEAT_SME_FA64 */ - cpu->isar.id_aa64smfr0 = t; + acc->isar.id_aa64smfr0 = t; /* Replicate the same data to the 32-bit id registers. */ - aa32_max_features(cpu); + aa32_max_features(acc); #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 = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */ - cpu->dcz_blocksize = 7; /* 512 bytes */ + acc->ctr = 0x80038003; /* 32 byte I and D cacheline size, VIPT icache */ + acc->dcz_blocksize = 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 @@ /* Share AArch32 -cpu max features with AArch64. */ -void aa32_max_features(ARMCPUClass *cpu) +void aa32_max_features(ARMCPUClass *acc) { uint32_t t; /* Add additional features supported by QEMU */ - t = cpu->isar.id_isar5; + t = acc->isar.id_isar5; t = FIELD_DP32(t, ID_ISAR5, AES, 2); /* FEAT_PMULL */ t = FIELD_DP32(t, ID_ISAR5, SHA1, 1); /* FEAT_SHA1 */ t = FIELD_DP32(t, ID_ISAR5, SHA2, 1); /* FEAT_SHA256 */ t = FIELD_DP32(t, ID_ISAR5, CRC32, 1); t = FIELD_DP32(t, ID_ISAR5, RDM, 1); /* FEAT_RDM */ t = FIELD_DP32(t, ID_ISAR5, VCMA, 1); /* FEAT_FCMA */ - cpu->isar.id_isar5 = t; + acc->isar.id_isar5 = t; - t = cpu->isar.id_isar6; + t = acc->isar.id_isar6; t = FIELD_DP32(t, ID_ISAR6, JSCVT, 1); /* FEAT_JSCVT */ t = FIELD_DP32(t, ID_ISAR6, DP, 1); /* Feat_DotProd */ t = FIELD_DP32(t, ID_ISAR6, FHM, 1); /* FEAT_FHM */ @@ -44,50 +44,50 @@ void aa32_max_features(ARMCPUClass *cpu) t = FIELD_DP32(t, ID_ISAR6, SPECRES, 1); /* FEAT_SPECRES */ t = FIELD_DP32(t, ID_ISAR6, BF16, 1); /* FEAT_AA32BF16 */ t = FIELD_DP32(t, ID_ISAR6, I8MM, 1); /* FEAT_AA32I8MM */ - cpu->isar.id_isar6 = t; + acc->isar.id_isar6 = t; - t = cpu->isar.mvfr1; + t = acc->isar.mvfr1; t = FIELD_DP32(t, MVFR1, FPHP, 3); /* FEAT_FP16 */ t = FIELD_DP32(t, MVFR1, SIMDHP, 2); /* FEAT_FP16 */ - cpu->isar.mvfr1 = t; + acc->isar.mvfr1 = t; - t = cpu->isar.mvfr2; + t = acc->isar.mvfr2; t = FIELD_DP32(t, MVFR2, SIMDMISC, 3); /* SIMD MaxNum */ t = FIELD_DP32(t, MVFR2, FPMISC, 4); /* FP MaxNum */ - cpu->isar.mvfr2 = t; + acc->isar.mvfr2 = t; - t = cpu->isar.id_mmfr3; + t = acc->isar.id_mmfr3; t = FIELD_DP32(t, ID_MMFR3, PAN, 2); /* FEAT_PAN2 */ - cpu->isar.id_mmfr3 = t; + acc->isar.id_mmfr3 = t; - t = cpu->isar.id_mmfr4; + t = acc->isar.id_mmfr4; t = FIELD_DP32(t, ID_MMFR4, HPDS, 1); /* FEAT_AA32HPD */ t = FIELD_DP32(t, ID_MMFR4, AC2, 1); /* ACTLR2, HACTLR2 */ t = FIELD_DP32(t, ID_MMFR4, CNP, 1); /* FEAT_TTCNP */ t = FIELD_DP32(t, ID_MMFR4, XNX, 1); /* FEAT_XNX */ t = FIELD_DP32(t, ID_MMFR4, EVT, 2); /* FEAT_EVT */ - cpu->isar.id_mmfr4 = t; + acc->isar.id_mmfr4 = t; - t = cpu->isar.id_mmfr5; + t = acc->isar.id_mmfr5; t = FIELD_DP32(t, ID_MMFR5, ETS, 1); /* FEAT_ETS */ - cpu->isar.id_mmfr5 = t; + acc->isar.id_mmfr5 = t; - t = cpu->isar.id_pfr0; + t = acc->isar.id_pfr0; t = FIELD_DP32(t, ID_PFR0, CSV2, 2); /* FEAT_CVS2 */ t = FIELD_DP32(t, ID_PFR0, DIT, 1); /* FEAT_DIT */ t = FIELD_DP32(t, ID_PFR0, RAS, 1); /* FEAT_RAS */ - cpu->isar.id_pfr0 = t; + acc->isar.id_pfr0 = t; - t = cpu->isar.id_pfr2; + t = acc->isar.id_pfr2; t = FIELD_DP32(t, ID_PFR2, CSV3, 1); /* FEAT_CSV3 */ t = FIELD_DP32(t, ID_PFR2, SSBS, 1); /* FEAT_SSBS */ - cpu->isar.id_pfr2 = t; + acc->isar.id_pfr2 = t; - t = cpu->isar.id_dfr0; + t = acc->isar.id_dfr0; t = FIELD_DP32(t, ID_DFR0, COPDBG, 9); /* FEAT_Debugv8p4 */ t = FIELD_DP32(t, ID_DFR0, COPSDBG, 9); /* FEAT_Debugv8p4 */ t = FIELD_DP32(t, ID_DFR0, PERFMON, 6); /* FEAT_PMUv3p5 */ - cpu->isar.id_dfr0 = t; + acc->isar.id_dfr0 = t; } #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 */ -static void arm926_class_init(ARMCPUClass *cpu) +static void arm926_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = 0x41069265; - cpu->reset_fpsid = 0x41011090; - cpu->ctr = 0x1dd20d2; - cpu->reset_sctlr = 0x00090078; + acc->dtb_compatible = "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 = 0x41069265; + acc->reset_fpsid = 0x41011090; + acc->ctr = 0x1dd20d2; + acc->reset_sctlr = 0x00090078; /* * 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 = FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELLE, 1); + acc->isar.id_isar1 = FIELD_DP32(acc->isar.id_isar1, ID_ISAR1, JAZELLE, 1); /* * Similarly, we need to set MVFR0 fields to enable vfp and short vector * support even though ARMv5 doesn't have this register. */ - cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); - cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSP, 1); - cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1); + acc->isar.mvfr0 = FIELD_DP32(acc->isar.mvfr0, MVFR0, FPSHVEC, 1); + acc->isar.mvfr0 = FIELD_DP32(acc->isar.mvfr0, MVFR0, FPSP, 1); + acc->isar.mvfr0 = FIELD_DP32(acc->isar.mvfr0, MVFR0, FPDP, 1); } -static void arm946_class_init(ARMCPUClass *cpu) +static void arm946_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = 0x41059461; - cpu->ctr = 0x0f004006; - cpu->reset_sctlr = 0x00000078; + acc->dtb_compatible = "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 = 0x41059461; + acc->ctr = 0x0f004006; + acc->reset_sctlr = 0x00000078; } -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] = { @@ -224,34 +224,34 @@ static void arm1026_class_init(ARMCPUClass *cpu) .resetvalue = 0 } }; - cpu->dtb_compatible = "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 = 0x4106a262; - cpu->reset_fpsid = 0x410110a0; - cpu->ctr = 0x1dd20d2; - cpu->reset_sctlr = 0x00090078; - cpu->reset_auxcr = 1; + acc->dtb_compatible = "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 = 0x4106a262; + acc->reset_fpsid = 0x410110a0; + acc->ctr = 0x1dd20d2; + acc->reset_sctlr = 0x00090078; + acc->reset_auxcr = 1; /* * 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 = FIELD_DP32(cpu->isar.id_isar1, ID_ISAR1, JAZELLE, 1); + acc->isar.id_isar1 = FIELD_DP32(acc->isar.id_isar1, ID_ISAR1, JAZELLE, 1); /* * Similarly, we need to set MVFR0 fields to enable vfp and short vector * support even though ARMv5 doesn't have this register. */ - cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); - cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSP, 1); - cpu->isar.mvfr0 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPDP, 1); + acc->isar.mvfr0 = FIELD_DP32(acc->isar.mvfr0, MVFR0, FPSHVEC, 1); + acc->isar.mvfr0 = FIELD_DP32(acc->isar.mvfr0, MVFR0, FPSP, 1); + acc->isar.mvfr0 = FIELD_DP32(acc->isar.mvfr0, MVFR0, FPDP, 1); - define_arm_cp_regs_with_class(cpu, ifar, NULL); + define_arm_cp_regs_with_class(acc, ifar, NULL); } -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). */ - cpu->dtb_compatible = "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 = 0x4107b362; - cpu->reset_fpsid = 0x410120b4; - cpu->isar.mvfr0 = 0x11111111; - cpu->isar.mvfr1 = 0x00000000; - cpu->ctr = 0x1dd20d2; - cpu->reset_sctlr = 0x00050078; - cpu->isar.id_pfr0 = 0x111; - cpu->isar.id_pfr1 = 0x1; - cpu->isar.id_dfr0 = 0x2; - cpu->id_afr0 = 0x3; - cpu->isar.id_mmfr0 = 0x01130003; - cpu->isar.id_mmfr1 = 0x10030302; - cpu->isar.id_mmfr2 = 0x01222110; - cpu->isar.id_isar0 = 0x00140011; - cpu->isar.id_isar1 = 0x12002111; - cpu->isar.id_isar2 = 0x11231111; - cpu->isar.id_isar3 = 0x01102131; - cpu->isar.id_isar4 = 0x141; - cpu->reset_auxcr = 7; + acc->dtb_compatible = "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 = 0x4107b362; + acc->reset_fpsid = 0x410120b4; + acc->isar.mvfr0 = 0x11111111; + acc->isar.mvfr1 = 0x00000000; + acc->ctr = 0x1dd20d2; + acc->reset_sctlr = 0x00050078; + acc->isar.id_pfr0 = 0x111; + acc->isar.id_pfr1 = 0x1; + acc->isar.id_dfr0 = 0x2; + acc->id_afr0 = 0x3; + acc->isar.id_mmfr0 = 0x01130003; + acc->isar.id_mmfr1 = 0x10030302; + acc->isar.id_mmfr2 = 0x01222110; + acc->isar.id_isar0 = 0x00140011; + acc->isar.id_isar1 = 0x12002111; + acc->isar.id_isar2 = 0x11231111; + acc->isar.id_isar3 = 0x01102131; + acc->isar.id_isar4 = 0x141; + acc->reset_auxcr = 7; } -static void arm1136_class_init(ARMCPUClass *cpu) +static void arm1136_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = 0x4117b363; - cpu->reset_fpsid = 0x410120b4; - cpu->isar.mvfr0 = 0x11111111; - cpu->isar.mvfr1 = 0x00000000; - cpu->ctr = 0x1dd20d2; - cpu->reset_sctlr = 0x00050078; - cpu->isar.id_pfr0 = 0x111; - cpu->isar.id_pfr1 = 0x1; - cpu->isar.id_dfr0 = 0x2; - cpu->id_afr0 = 0x3; - cpu->isar.id_mmfr0 = 0x01130003; - cpu->isar.id_mmfr1 = 0x10030302; - cpu->isar.id_mmfr2 = 0x01222110; - cpu->isar.id_isar0 = 0x00140011; - cpu->isar.id_isar1 = 0x12002111; - cpu->isar.id_isar2 = 0x11231111; - cpu->isar.id_isar3 = 0x01102131; - cpu->isar.id_isar4 = 0x141; - cpu->reset_auxcr = 7; + acc->dtb_compatible = "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 = 0x4117b363; + acc->reset_fpsid = 0x410120b4; + acc->isar.mvfr0 = 0x11111111; + acc->isar.mvfr1 = 0x00000000; + acc->ctr = 0x1dd20d2; + acc->reset_sctlr = 0x00050078; + acc->isar.id_pfr0 = 0x111; + acc->isar.id_pfr1 = 0x1; + acc->isar.id_dfr0 = 0x2; + acc->id_afr0 = 0x3; + acc->isar.id_mmfr0 = 0x01130003; + acc->isar.id_mmfr1 = 0x10030302; + acc->isar.id_mmfr2 = 0x01222110; + acc->isar.id_isar0 = 0x00140011; + acc->isar.id_isar1 = 0x12002111; + acc->isar.id_isar2 = 0x11231111; + acc->isar.id_isar3 = 0x01102131; + acc->isar.id_isar4 = 0x141; + acc->reset_auxcr = 7; } -static void arm1176_class_init(ARMCPUClass *cpu) +static void arm1176_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = 0x410fb767; - cpu->reset_fpsid = 0x410120b5; - cpu->isar.mvfr0 = 0x11111111; - cpu->isar.mvfr1 = 0x00000000; - cpu->ctr = 0x1dd20d2; - cpu->reset_sctlr = 0x00050078; - cpu->isar.id_pfr0 = 0x111; - cpu->isar.id_pfr1 = 0x11; - cpu->isar.id_dfr0 = 0x33; - cpu->id_afr0 = 0; - cpu->isar.id_mmfr0 = 0x01130003; - cpu->isar.id_mmfr1 = 0x10030302; - cpu->isar.id_mmfr2 = 0x01222100; - cpu->isar.id_isar0 = 0x0140011; - cpu->isar.id_isar1 = 0x12002111; - cpu->isar.id_isar2 = 0x11231121; - cpu->isar.id_isar3 = 0x01102131; - cpu->isar.id_isar4 = 0x01141; - cpu->reset_auxcr = 7; + acc->dtb_compatible = "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 = 0x410fb767; + acc->reset_fpsid = 0x410120b5; + acc->isar.mvfr0 = 0x11111111; + acc->isar.mvfr1 = 0x00000000; + acc->ctr = 0x1dd20d2; + acc->reset_sctlr = 0x00050078; + acc->isar.id_pfr0 = 0x111; + acc->isar.id_pfr1 = 0x11; + acc->isar.id_dfr0 = 0x33; + acc->id_afr0 = 0; + acc->isar.id_mmfr0 = 0x01130003; + acc->isar.id_mmfr1 = 0x10030302; + acc->isar.id_mmfr2 = 0x01222100; + acc->isar.id_isar0 = 0x0140011; + acc->isar.id_isar1 = 0x12002111; + acc->isar.id_isar2 = 0x11231121; + acc->isar.id_isar3 = 0x01102131; + acc->isar.id_isar4 = 0x01141; + acc->reset_auxcr = 7; } -static void arm11mpcore_class_init(ARMCPUClass *cpu) +static void arm11mpcore_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = 0x410fb022; - cpu->reset_fpsid = 0x410120b4; - cpu->isar.mvfr0 = 0x11111111; - cpu->isar.mvfr1 = 0x00000000; - cpu->ctr = 0x1d192992; /* 32K icache 32K dcache */ - cpu->isar.id_pfr0 = 0x111; - cpu->isar.id_pfr1 = 0x1; - cpu->isar.id_dfr0 = 0; - cpu->id_afr0 = 0x2; - cpu->isar.id_mmfr0 = 0x01100103; - cpu->isar.id_mmfr1 = 0x10020302; - cpu->isar.id_mmfr2 = 0x01222000; - cpu->isar.id_isar0 = 0x00100011; - cpu->isar.id_isar1 = 0x12002111; - cpu->isar.id_isar2 = 0x11221011; - cpu->isar.id_isar3 = 0x01102131; - cpu->isar.id_isar4 = 0x141; - cpu->reset_auxcr = 1; + acc->dtb_compatible = "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 = 0x410fb022; + acc->reset_fpsid = 0x410120b4; + acc->isar.mvfr0 = 0x11111111; + acc->isar.mvfr1 = 0x00000000; + acc->ctr = 0x1d192992; /* 32K icache 32K dcache */ + acc->isar.id_pfr0 = 0x111; + acc->isar.id_pfr1 = 0x1; + acc->isar.id_dfr0 = 0; + acc->id_afr0 = 0x2; + acc->isar.id_mmfr0 = 0x01100103; + acc->isar.id_mmfr1 = 0x10020302; + acc->isar.id_mmfr2 = 0x01222000; + acc->isar.id_isar0 = 0x00100011; + acc->isar.id_isar1 = 0x12002111; + acc->isar.id_isar2 = 0x11221011; + acc->isar.id_isar3 = 0x01102131; + acc->isar.id_isar4 = 0x141; + acc->reset_auxcr = 1; } static const ARMCPRegInfo cortexa8_cp_reginfo[] = { @@ -381,41 +381,41 @@ static const ARMCPRegInfo cortexa8_cp_reginfo[] = { .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, }; -static void cortex_a8_class_init(ARMCPUClass *cpu) +static void cortex_a8_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = 0x410fc080; - cpu->reset_fpsid = 0x410330c0; - cpu->isar.mvfr0 = 0x11110222; - cpu->isar.mvfr1 = 0x00011111; - cpu->ctr = 0x82048004; - cpu->reset_sctlr = 0x00c50078; - cpu->isar.id_pfr0 = 0x1031; - cpu->isar.id_pfr1 = 0x11; - cpu->isar.id_dfr0 = 0x400; - cpu->id_afr0 = 0; - cpu->isar.id_mmfr0 = 0x31100003; - cpu->isar.id_mmfr1 = 0x20000000; - cpu->isar.id_mmfr2 = 0x01202000; - cpu->isar.id_mmfr3 = 0x11; - cpu->isar.id_isar0 = 0x00101111; - cpu->isar.id_isar1 = 0x12112111; - cpu->isar.id_isar2 = 0x21232031; - cpu->isar.id_isar3 = 0x11112131; - cpu->isar.id_isar4 = 0x00111142; - cpu->isar.dbgdidr = 0x15141000; - cpu->clidr = (1 << 27) | (2 << 24) | 3; - cpu->ccsidr[0] = 0xe007e01a; /* 16k L1 dcache. */ - cpu->ccsidr[1] = 0x2007e01a; /* 16k L1 icache. */ - cpu->ccsidr[2] = 0xf0000000; /* No L2 icache. */ - cpu->reset_auxcr = 2; - cpu->isar.reset_pmcr_el0 = 0x41002000; - define_arm_cp_regs_with_class(cpu, cortexa8_cp_reginfo, NULL); + acc->dtb_compatible = "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 = 0x410fc080; + acc->reset_fpsid = 0x410330c0; + acc->isar.mvfr0 = 0x11110222; + acc->isar.mvfr1 = 0x00011111; + acc->ctr = 0x82048004; + acc->reset_sctlr = 0x00c50078; + acc->isar.id_pfr0 = 0x1031; + acc->isar.id_pfr1 = 0x11; + acc->isar.id_dfr0 = 0x400; + acc->id_afr0 = 0; + acc->isar.id_mmfr0 = 0x31100003; + acc->isar.id_mmfr1 = 0x20000000; + acc->isar.id_mmfr2 = 0x01202000; + acc->isar.id_mmfr3 = 0x11; + acc->isar.id_isar0 = 0x00101111; + acc->isar.id_isar1 = 0x12112111; + acc->isar.id_isar2 = 0x21232031; + acc->isar.id_isar3 = 0x11112131; + acc->isar.id_isar4 = 0x00111142; + acc->isar.dbgdidr = 0x15141000; + acc->clidr = (1 << 27) | (2 << 24) | 3; + acc->ccsidr[0] = 0xe007e01a; /* 16k L1 dcache. */ + acc->ccsidr[1] = 0x2007e01a; /* 16k L1 icache. */ + acc->ccsidr[2] = 0xf0000000; /* No L2 icache. */ + acc->reset_auxcr = 2; + acc->isar.reset_pmcr_el0 = 0x41002000; + define_arm_cp_regs_with_class(acc, cortexa8_cp_reginfo, NULL); } static const ARMCPRegInfo cortexa9_cp_reginfo[] = { @@ -447,45 +447,45 @@ static const ARMCPRegInfo cortexa9_cp_reginfo[] = { .access = PL1_RW, .resetvalue = 0, .type = ARM_CP_CONST }, }; -static void cortex_a9_class_init(ARMCPUClass *cpu) +static void cortex_a9_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = "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 = 0x410fc090; - cpu->reset_fpsid = 0x41033090; - cpu->isar.mvfr0 = 0x11110222; - cpu->isar.mvfr1 = 0x01111111; - cpu->ctr = 0x80038003; - cpu->reset_sctlr = 0x00c50078; - cpu->isar.id_pfr0 = 0x1031; - cpu->isar.id_pfr1 = 0x11; - cpu->isar.id_dfr0 = 0x000; - cpu->id_afr0 = 0; - cpu->isar.id_mmfr0 = 0x00100103; - cpu->isar.id_mmfr1 = 0x20000000; - cpu->isar.id_mmfr2 = 0x01230000; - cpu->isar.id_mmfr3 = 0x00002111; - cpu->isar.id_isar0 = 0x00101111; - cpu->isar.id_isar1 = 0x13112111; - cpu->isar.id_isar2 = 0x21232041; - cpu->isar.id_isar3 = 0x11112131; - cpu->isar.id_isar4 = 0x00111142; - cpu->isar.dbgdidr = 0x35141000; - cpu->clidr = (1 << 27) | (1 << 24) | 3; - cpu->ccsidr[0] = 0xe00fe019; /* 16k L1 dcache. */ - cpu->ccsidr[1] = 0x200fe019; /* 16k L1 icache. */ - cpu->isar.reset_pmcr_el0 = 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 = 0x410fc090; + acc->reset_fpsid = 0x41033090; + acc->isar.mvfr0 = 0x11110222; + acc->isar.mvfr1 = 0x01111111; + acc->ctr = 0x80038003; + acc->reset_sctlr = 0x00c50078; + acc->isar.id_pfr0 = 0x1031; + acc->isar.id_pfr1 = 0x11; + acc->isar.id_dfr0 = 0x000; + acc->id_afr0 = 0; + acc->isar.id_mmfr0 = 0x00100103; + acc->isar.id_mmfr1 = 0x20000000; + acc->isar.id_mmfr2 = 0x01230000; + acc->isar.id_mmfr3 = 0x00002111; + acc->isar.id_isar0 = 0x00101111; + acc->isar.id_isar1 = 0x13112111; + acc->isar.id_isar2 = 0x21232041; + acc->isar.id_isar3 = 0x11112131; + acc->isar.id_isar4 = 0x00111142; + acc->isar.dbgdidr = 0x35141000; + acc->clidr = (1 << 27) | (1 << 24) | 3; + acc->ccsidr[0] = 0xe00fe019; /* 16k L1 dcache. */ + acc->ccsidr[1] = 0x200fe019; /* 16k L1 icache. */ + acc->isar.reset_pmcr_el0 = 0x41093000; + define_arm_cp_regs_with_class(acc, cortexa9_cp_reginfo, NULL); } #ifndef CONFIG_USER_ONLY @@ -511,106 +511,106 @@ static const ARMCPRegInfo cortexa15_cp_reginfo[] = { .access = PL1_RW, .type = ARM_CP_CONST, .resetvalue = 0 }, }; -static void cortex_a7_class_init(ARMCPUClass *cpu) +static void cortex_a7_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = QEMU_KVM_ARM_TARGET_CORTEX_A7; - cpu->midr = 0x410fc075; - cpu->reset_fpsid = 0x41023075; - cpu->isar.mvfr0 = 0x10110222; - cpu->isar.mvfr1 = 0x11111111; - cpu->ctr = 0x84448003; - cpu->reset_sctlr = 0x00c50078; - cpu->isar.id_pfr0 = 0x00001131; - cpu->isar.id_pfr1 = 0x00011011; - cpu->isar.id_dfr0 = 0x02010555; - cpu->id_afr0 = 0x00000000; - cpu->isar.id_mmfr0 = 0x10101105; - cpu->isar.id_mmfr1 = 0x40000000; - cpu->isar.id_mmfr2 = 0x01240000; - cpu->isar.id_mmfr3 = 0x02102211; + acc->dtb_compatible = "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 = QEMU_KVM_ARM_TARGET_CORTEX_A7; + acc->midr = 0x410fc075; + acc->reset_fpsid = 0x41023075; + acc->isar.mvfr0 = 0x10110222; + acc->isar.mvfr1 = 0x11111111; + acc->ctr = 0x84448003; + acc->reset_sctlr = 0x00c50078; + acc->isar.id_pfr0 = 0x00001131; + acc->isar.id_pfr1 = 0x00011011; + acc->isar.id_dfr0 = 0x02010555; + acc->id_afr0 = 0x00000000; + acc->isar.id_mmfr0 = 0x10101105; + acc->isar.id_mmfr1 = 0x40000000; + acc->isar.id_mmfr2 = 0x01240000; + acc->isar.id_mmfr3 = 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 = 0x02101110; - cpu->isar.id_isar1 = 0x13112111; - cpu->isar.id_isar2 = 0x21232041; - cpu->isar.id_isar3 = 0x11112131; - cpu->isar.id_isar4 = 0x10011142; - cpu->isar.dbgdidr = 0x3515f005; - cpu->isar.dbgdevid = 0x01110f13; - cpu->isar.dbgdevid1 = 0x1; - cpu->clidr = 0x0a200023; - cpu->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */ - cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */ - cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */ - cpu->isar.reset_pmcr_el0 = 0x41072000; + acc->isar.id_isar0 = 0x02101110; + acc->isar.id_isar1 = 0x13112111; + acc->isar.id_isar2 = 0x21232041; + acc->isar.id_isar3 = 0x11112131; + acc->isar.id_isar4 = 0x10011142; + acc->isar.dbgdidr = 0x3515f005; + acc->isar.dbgdevid = 0x01110f13; + acc->isar.dbgdevid1 = 0x1; + acc->clidr = 0x0a200023; + acc->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */ + acc->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */ + acc->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */ + acc->isar.reset_pmcr_el0 = 0x41072000; /* 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); } -static void cortex_a15_class_init(ARMCPUClass *cpu) +static void cortex_a15_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = QEMU_KVM_ARM_TARGET_CORTEX_A15; - /* r4p0 cpu, not requiring expensive tlb flush errata */ - cpu->midr = 0x414fc0f0; - cpu->revidr = 0x0; - cpu->reset_fpsid = 0x410430f0; - cpu->isar.mvfr0 = 0x10110222; - cpu->isar.mvfr1 = 0x11111111; - cpu->ctr = 0x8444c004; - cpu->reset_sctlr = 0x00c50078; - cpu->isar.id_pfr0 = 0x00001131; - cpu->isar.id_pfr1 = 0x00011011; - cpu->isar.id_dfr0 = 0x02010555; - cpu->id_afr0 = 0x00000000; - cpu->isar.id_mmfr0 = 0x10201105; - cpu->isar.id_mmfr1 = 0x20000000; - cpu->isar.id_mmfr2 = 0x01240000; - cpu->isar.id_mmfr3 = 0x02102211; - cpu->isar.id_isar0 = 0x02101110; - cpu->isar.id_isar1 = 0x13112111; - cpu->isar.id_isar2 = 0x21232041; - cpu->isar.id_isar3 = 0x11112131; - cpu->isar.id_isar4 = 0x10011142; - cpu->isar.dbgdidr = 0x3515f021; - cpu->isar.dbgdevid = 0x01110f13; - cpu->isar.dbgdevid1 = 0x0; - cpu->clidr = 0x0a200023; - cpu->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */ - cpu->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */ - cpu->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */ - cpu->isar.reset_pmcr_el0 = 0x410F3000; - define_arm_cp_regs_with_class(cpu, cortexa15_cp_reginfo, NULL); + acc->dtb_compatible = "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 = QEMU_KVM_ARM_TARGET_CORTEX_A15; + /* r4p0 acc, not requiring expensive tlb flush errata */ + acc->midr = 0x414fc0f0; + acc->revidr = 0x0; + acc->reset_fpsid = 0x410430f0; + acc->isar.mvfr0 = 0x10110222; + acc->isar.mvfr1 = 0x11111111; + acc->ctr = 0x8444c004; + acc->reset_sctlr = 0x00c50078; + acc->isar.id_pfr0 = 0x00001131; + acc->isar.id_pfr1 = 0x00011011; + acc->isar.id_dfr0 = 0x02010555; + acc->id_afr0 = 0x00000000; + acc->isar.id_mmfr0 = 0x10201105; + acc->isar.id_mmfr1 = 0x20000000; + acc->isar.id_mmfr2 = 0x01240000; + acc->isar.id_mmfr3 = 0x02102211; + acc->isar.id_isar0 = 0x02101110; + acc->isar.id_isar1 = 0x13112111; + acc->isar.id_isar2 = 0x21232041; + acc->isar.id_isar3 = 0x11112131; + acc->isar.id_isar4 = 0x10011142; + acc->isar.dbgdidr = 0x3515f021; + acc->isar.dbgdevid = 0x01110f13; + acc->isar.dbgdevid1 = 0x0; + acc->clidr = 0x0a200023; + acc->ccsidr[0] = 0x701fe00a; /* 32K L1 dcache */ + acc->ccsidr[1] = 0x201fe00a; /* 32K L1 icache */ + acc->ccsidr[2] = 0x711fe07a; /* 4096K L2 unified cache */ + acc->isar.reset_pmcr_el0 = 0x410F3000; + define_arm_cp_regs_with_class(acc, cortexa15_cp_reginfo, NULL); } -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); - cpu->midr = 0x410cc200; + acc->midr = 0x410cc200; /* * 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 = 0x00000030; - cpu->isar.id_pfr1 = 0x00000200; - cpu->isar.id_dfr0 = 0x00100000; - cpu->id_afr0 = 0x00000000; - cpu->isar.id_mmfr0 = 0x00000030; - cpu->isar.id_mmfr1 = 0x00000000; - cpu->isar.id_mmfr2 = 0x00000000; - cpu->isar.id_mmfr3 = 0x00000000; - cpu->isar.id_isar0 = 0x01141110; - cpu->isar.id_isar1 = 0x02111000; - cpu->isar.id_isar2 = 0x21112231; - cpu->isar.id_isar3 = 0x01111110; - cpu->isar.id_isar4 = 0x01310102; - cpu->isar.id_isar5 = 0x00000000; - cpu->isar.id_isar6 = 0x00000000; + acc->isar.id_pfr0 = 0x00000030; + acc->isar.id_pfr1 = 0x00000200; + acc->isar.id_dfr0 = 0x00100000; + acc->id_afr0 = 0x00000000; + acc->isar.id_mmfr0 = 0x00000030; + acc->isar.id_mmfr1 = 0x00000000; + acc->isar.id_mmfr2 = 0x00000000; + acc->isar.id_mmfr3 = 0x00000000; + acc->isar.id_isar0 = 0x01141110; + acc->isar.id_isar1 = 0x02111000; + acc->isar.id_isar2 = 0x21112231; + acc->isar.id_isar3 = 0x01111110; + acc->isar.id_isar4 = 0x01310102; + acc->isar.id_isar5 = 0x00000000; + acc->isar.id_isar6 = 0x00000000; } -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 = 0x410fc231; - cpu->pmsav7_dregion = 8; - cpu->isar.id_pfr0 = 0x00000030; - cpu->isar.id_pfr1 = 0x00000200; - cpu->isar.id_dfr0 = 0x00100000; - cpu->id_afr0 = 0x00000000; - cpu->isar.id_mmfr0 = 0x00000030; - cpu->isar.id_mmfr1 = 0x00000000; - cpu->isar.id_mmfr2 = 0x00000000; - cpu->isar.id_mmfr3 = 0x00000000; - cpu->isar.id_isar0 = 0x01141110; - cpu->isar.id_isar1 = 0x02111000; - cpu->isar.id_isar2 = 0x21112231; - cpu->isar.id_isar3 = 0x01111110; - cpu->isar.id_isar4 = 0x01310102; - cpu->isar.id_isar5 = 0x00000000; - cpu->isar.id_isar6 = 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 = 0x410fc231; + acc->pmsav7_dregion = 8; + acc->isar.id_pfr0 = 0x00000030; + acc->isar.id_pfr1 = 0x00000200; + acc->isar.id_dfr0 = 0x00100000; + acc->id_afr0 = 0x00000000; + acc->isar.id_mmfr0 = 0x00000030; + acc->isar.id_mmfr1 = 0x00000000; + acc->isar.id_mmfr2 = 0x00000000; + acc->isar.id_mmfr3 = 0x00000000; + acc->isar.id_isar0 = 0x01141110; + acc->isar.id_isar1 = 0x02111000; + acc->isar.id_isar2 = 0x21112231; + acc->isar.id_isar3 = 0x01111110; + acc->isar.id_isar4 = 0x01310102; + acc->isar.id_isar5 = 0x00000000; + acc->isar.id_isar6 = 0x00000000; } -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 = 0x410fc240; /* r0p0 */ - cpu->pmsav7_dregion = 8; - cpu->isar.mvfr0 = 0x10110021; - cpu->isar.mvfr1 = 0x11000011; - cpu->isar.mvfr2 = 0x00000000; - cpu->isar.id_pfr0 = 0x00000030; - cpu->isar.id_pfr1 = 0x00000200; - cpu->isar.id_dfr0 = 0x00100000; - cpu->id_afr0 = 0x00000000; - cpu->isar.id_mmfr0 = 0x00000030; - cpu->isar.id_mmfr1 = 0x00000000; - cpu->isar.id_mmfr2 = 0x00000000; - cpu->isar.id_mmfr3 = 0x00000000; - cpu->isar.id_isar0 = 0x01141110; - cpu->isar.id_isar1 = 0x02111000; - cpu->isar.id_isar2 = 0x21112231; - cpu->isar.id_isar3 = 0x01111110; - cpu->isar.id_isar4 = 0x01310102; - cpu->isar.id_isar5 = 0x00000000; - cpu->isar.id_isar6 = 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 = 0x410fc240; /* r0p0 */ + acc->pmsav7_dregion = 8; + acc->isar.mvfr0 = 0x10110021; + acc->isar.mvfr1 = 0x11000011; + acc->isar.mvfr2 = 0x00000000; + acc->isar.id_pfr0 = 0x00000030; + acc->isar.id_pfr1 = 0x00000200; + acc->isar.id_dfr0 = 0x00100000; + acc->id_afr0 = 0x00000000; + acc->isar.id_mmfr0 = 0x00000030; + acc->isar.id_mmfr1 = 0x00000000; + acc->isar.id_mmfr2 = 0x00000000; + acc->isar.id_mmfr3 = 0x00000000; + acc->isar.id_isar0 = 0x01141110; + acc->isar.id_isar1 = 0x02111000; + acc->isar.id_isar2 = 0x21112231; + acc->isar.id_isar3 = 0x01111110; + acc->isar.id_isar4 = 0x01310102; + acc->isar.id_isar5 = 0x00000000; + acc->isar.id_isar6 = 0x00000000; } -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 = 0x411fc272; /* r1p2 */ - cpu->pmsav7_dregion = 8; - cpu->isar.mvfr0 = 0x10110221; - cpu->isar.mvfr1 = 0x12000011; - cpu->isar.mvfr2 = 0x00000040; - cpu->isar.id_pfr0 = 0x00000030; - cpu->isar.id_pfr1 = 0x00000200; - cpu->isar.id_dfr0 = 0x00100000; - cpu->id_afr0 = 0x00000000; - cpu->isar.id_mmfr0 = 0x00100030; - cpu->isar.id_mmfr1 = 0x00000000; - cpu->isar.id_mmfr2 = 0x01000000; - cpu->isar.id_mmfr3 = 0x00000000; - cpu->isar.id_isar0 = 0x01101110; - cpu->isar.id_isar1 = 0x02112000; - cpu->isar.id_isar2 = 0x20232231; - cpu->isar.id_isar3 = 0x01111131; - cpu->isar.id_isar4 = 0x01310132; - cpu->isar.id_isar5 = 0x00000000; - cpu->isar.id_isar6 = 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 = 0x411fc272; /* r1p2 */ + acc->pmsav7_dregion = 8; + acc->isar.mvfr0 = 0x10110221; + acc->isar.mvfr1 = 0x12000011; + acc->isar.mvfr2 = 0x00000040; + acc->isar.id_pfr0 = 0x00000030; + acc->isar.id_pfr1 = 0x00000200; + acc->isar.id_dfr0 = 0x00100000; + acc->id_afr0 = 0x00000000; + acc->isar.id_mmfr0 = 0x00100030; + acc->isar.id_mmfr1 = 0x00000000; + acc->isar.id_mmfr2 = 0x01000000; + acc->isar.id_mmfr3 = 0x00000000; + acc->isar.id_isar0 = 0x01101110; + acc->isar.id_isar1 = 0x02112000; + acc->isar.id_isar2 = 0x20232231; + acc->isar.id_isar3 = 0x01111131; + acc->isar.id_isar4 = 0x01310132; + acc->isar.id_isar5 = 0x00000000; + acc->isar.id_isar6 = 0x00000000; } -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 = 0x410fd213; /* r0p3 */ - cpu->pmsav7_dregion = 16; - cpu->sau_sregion = 8; - cpu->isar.mvfr0 = 0x10110021; - cpu->isar.mvfr1 = 0x11000011; - cpu->isar.mvfr2 = 0x00000040; - cpu->isar.id_pfr0 = 0x00000030; - cpu->isar.id_pfr1 = 0x00000210; - cpu->isar.id_dfr0 = 0x00200000; - cpu->id_afr0 = 0x00000000; - cpu->isar.id_mmfr0 = 0x00101F40; - cpu->isar.id_mmfr1 = 0x00000000; - cpu->isar.id_mmfr2 = 0x01000000; - cpu->isar.id_mmfr3 = 0x00000000; - cpu->isar.id_isar0 = 0x01101110; - cpu->isar.id_isar1 = 0x02212000; - cpu->isar.id_isar2 = 0x20232232; - cpu->isar.id_isar3 = 0x01111131; - cpu->isar.id_isar4 = 0x01310132; - cpu->isar.id_isar5 = 0x00000000; - cpu->isar.id_isar6 = 0x00000000; - cpu->clidr = 0x00000000; - cpu->ctr = 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 = 0x410fd213; /* r0p3 */ + acc->pmsav7_dregion = 16; + acc->sau_sregion = 8; + acc->isar.mvfr0 = 0x10110021; + acc->isar.mvfr1 = 0x11000011; + acc->isar.mvfr2 = 0x00000040; + acc->isar.id_pfr0 = 0x00000030; + acc->isar.id_pfr1 = 0x00000210; + acc->isar.id_dfr0 = 0x00200000; + acc->id_afr0 = 0x00000000; + acc->isar.id_mmfr0 = 0x00101F40; + acc->isar.id_mmfr1 = 0x00000000; + acc->isar.id_mmfr2 = 0x01000000; + acc->isar.id_mmfr3 = 0x00000000; + acc->isar.id_isar0 = 0x01101110; + acc->isar.id_isar1 = 0x02212000; + acc->isar.id_isar2 = 0x20232232; + acc->isar.id_isar3 = 0x01111131; + acc->isar.id_isar4 = 0x01310132; + acc->isar.id_isar5 = 0x00000000; + acc->isar.id_isar6 = 0x00000000; + acc->clidr = 0x00000000; + acc->ctr = 0x8000c000; } -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 = 0x410fd221; /* r0p1 */ - cpu->revidr = 0; - cpu->pmsav7_dregion = 16; - cpu->sau_sregion = 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 = 0x410fd221; /* r0p1 */ + acc->revidr = 0; + acc->pmsav7_dregion = 16; + acc->sau_sregion = 8; /* These are the MVFR* values for the FPU + full MVE configuration */ - cpu->isar.mvfr0 = 0x10110221; - cpu->isar.mvfr1 = 0x12100211; - cpu->isar.mvfr2 = 0x00000040; - cpu->isar.id_pfr0 = 0x20000030; - cpu->isar.id_pfr1 = 0x00000230; - cpu->isar.id_dfr0 = 0x10200000; - cpu->id_afr0 = 0x00000000; - cpu->isar.id_mmfr0 = 0x00111040; - cpu->isar.id_mmfr1 = 0x00000000; - cpu->isar.id_mmfr2 = 0x01000000; - cpu->isar.id_mmfr3 = 0x00000011; - cpu->isar.id_isar0 = 0x01103110; - cpu->isar.id_isar1 = 0x02212000; - cpu->isar.id_isar2 = 0x20232232; - cpu->isar.id_isar3 = 0x01111131; - cpu->isar.id_isar4 = 0x01310132; - cpu->isar.id_isar5 = 0x00000000; - cpu->isar.id_isar6 = 0x00000000; - cpu->clidr = 0x00000000; /* caches not implemented */ - cpu->ctr = 0x8303c003; + acc->isar.mvfr0 = 0x10110221; + acc->isar.mvfr1 = 0x12100211; + acc->isar.mvfr2 = 0x00000040; + acc->isar.id_pfr0 = 0x20000030; + acc->isar.id_pfr1 = 0x00000230; + acc->isar.id_dfr0 = 0x10200000; + acc->id_afr0 = 0x00000000; + acc->isar.id_mmfr0 = 0x00111040; + acc->isar.id_mmfr1 = 0x00000000; + acc->isar.id_mmfr2 = 0x01000000; + acc->isar.id_mmfr3 = 0x00000011; + acc->isar.id_isar0 = 0x01103110; + acc->isar.id_isar1 = 0x02212000; + acc->isar.id_isar2 = 0x20232232; + acc->isar.id_isar3 = 0x01111131; + acc->isar.id_isar4 = 0x01310132; + acc->isar.id_isar5 = 0x00000000; + acc->isar.id_isar6 = 0x00000000; + acc->clidr = 0x00000000; /* caches not implemented */ + acc->ctr = 0x8303c003; } static const ARMCPRegInfo cortexr5_cp_reginfo[] = { @@ -794,180 +794,180 @@ static const ARMCPRegInfo cortexr5_cp_reginfo[] = { .opc2 = 0, .access = PL1_W, .type = ARM_CP_NOP }, }; -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 = 0x411fc153; /* r1p3 */ - cpu->isar.id_pfr0 = 0x0131; - cpu->isar.id_pfr1 = 0x001; - cpu->isar.id_dfr0 = 0x010400; - cpu->id_afr0 = 0x0; - cpu->isar.id_mmfr0 = 0x0210030; - cpu->isar.id_mmfr1 = 0x00000000; - cpu->isar.id_mmfr2 = 0x01200000; - cpu->isar.id_mmfr3 = 0x0211; - cpu->isar.id_isar0 = 0x02101111; - cpu->isar.id_isar1 = 0x13112111; - cpu->isar.id_isar2 = 0x21232141; - cpu->isar.id_isar3 = 0x01112131; - cpu->isar.id_isar4 = 0x0010142; - cpu->isar.id_isar5 = 0x0; - cpu->isar.id_isar6 = 0x0; - cpu->pmsav7_dregion = 16; - cpu->isar.reset_pmcr_el0 = 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 = 0x411fc153; /* r1p3 */ + acc->isar.id_pfr0 = 0x0131; + acc->isar.id_pfr1 = 0x001; + acc->isar.id_dfr0 = 0x010400; + acc->id_afr0 = 0x0; + acc->isar.id_mmfr0 = 0x0210030; + acc->isar.id_mmfr1 = 0x00000000; + acc->isar.id_mmfr2 = 0x01200000; + acc->isar.id_mmfr3 = 0x0211; + acc->isar.id_isar0 = 0x02101111; + acc->isar.id_isar1 = 0x13112111; + acc->isar.id_isar2 = 0x21232141; + acc->isar.id_isar3 = 0x01112131; + acc->isar.id_isar4 = 0x0010142; + acc->isar.id_isar5 = 0x0; + acc->isar.id_isar6 = 0x0; + acc->pmsav7_dregion = 16; + acc->isar.reset_pmcr_el0 = 0x41151800; + define_arm_cp_regs_with_class(acc, cortexr5_cp_reginfo, NULL); } -static void cortex_r5f_class_init(ARMCPUClass *cpu) +static void cortex_r5f_class_init(ARMCPUClass *acc) { - cortex_r5_class_init(cpu); - cpu->isar.mvfr0 = 0x10110221; - cpu->isar.mvfr1 = 0x00000011; + cortex_r5_class_init(acc); + acc->isar.mvfr0 = 0x10110221; + acc->isar.mvfr1 = 0x00000011; } -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 = ARM_CPUID_TI925T; - cpu->ctr = 0x5109149; - cpu->reset_sctlr = 0x00000070; + set_class_feature(acc, ARM_FEATURE_V4T); + set_class_feature(acc, ARM_FEATURE_OMAPCP); + acc->midr = ARM_CPUID_TI925T; + acc->ctr = 0x5109149; + acc->reset_sctlr = 0x00000070; } -static void sa1100_class_init(ARMCPUClass *cpu) +static void sa1100_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "intel,sa1100"; - set_class_feature(cpu, ARM_FEATURE_STRONGARM); - set_class_feature(cpu, ARM_FEATURE_DUMMY_C15_REGS); - cpu->midr = 0x4401A11B; - cpu->reset_sctlr = 0x00000070; + acc->dtb_compatible = "intel,sa1100"; + set_class_feature(acc, ARM_FEATURE_STRONGARM); + set_class_feature(acc, ARM_FEATURE_DUMMY_C15_REGS); + acc->midr = 0x4401A11B; + acc->reset_sctlr = 0x00000070; } -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 = 0x6901B119; - cpu->reset_sctlr = 0x00000070; + set_class_feature(acc, ARM_FEATURE_STRONGARM); + set_class_feature(acc, ARM_FEATURE_DUMMY_C15_REGS); + acc->midr = 0x6901B119; + acc->reset_sctlr = 0x00000070; } -static void pxa250_class_init(ARMCPUClass *cpu) +static void pxa250_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "marvell,xscale"; - set_class_feature(cpu, ARM_FEATURE_V5); - set_class_feature(cpu, ARM_FEATURE_XSCALE); - cpu->midr = 0x69052100; - cpu->ctr = 0xd172172; - cpu->reset_sctlr = 0x00000078; + acc->dtb_compatible = "marvell,xscale"; + set_class_feature(acc, ARM_FEATURE_V5); + set_class_feature(acc, ARM_FEATURE_XSCALE); + acc->midr = 0x69052100; + acc->ctr = 0xd172172; + acc->reset_sctlr = 0x00000078; } -static void pxa255_class_init(ARMCPUClass *cpu) +static void pxa255_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "marvell,xscale"; - set_class_feature(cpu, ARM_FEATURE_V5); - set_class_feature(cpu, ARM_FEATURE_XSCALE); - cpu->midr = 0x69052d00; - cpu->ctr = 0xd172172; - cpu->reset_sctlr = 0x00000078; + acc->dtb_compatible = "marvell,xscale"; + set_class_feature(acc, ARM_FEATURE_V5); + set_class_feature(acc, ARM_FEATURE_XSCALE); + acc->midr = 0x69052d00; + acc->ctr = 0xd172172; + acc->reset_sctlr = 0x00000078; } -static void pxa260_class_init(ARMCPUClass *cpu) +static void pxa260_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "marvell,xscale"; - set_class_feature(cpu, ARM_FEATURE_V5); - set_class_feature(cpu, ARM_FEATURE_XSCALE); - cpu->midr = 0x69052903; - cpu->ctr = 0xd172172; - cpu->reset_sctlr = 0x00000078; + acc->dtb_compatible = "marvell,xscale"; + set_class_feature(acc, ARM_FEATURE_V5); + set_class_feature(acc, ARM_FEATURE_XSCALE); + acc->midr = 0x69052903; + acc->ctr = 0xd172172; + acc->reset_sctlr = 0x00000078; } -static void pxa261_class_init(ARMCPUClass *cpu) +static void pxa261_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "marvell,xscale"; - set_class_feature(cpu, ARM_FEATURE_V5); - set_class_feature(cpu, ARM_FEATURE_XSCALE); - cpu->midr = 0x69052d05; - cpu->ctr = 0xd172172; - cpu->reset_sctlr = 0x00000078; + acc->dtb_compatible = "marvell,xscale"; + set_class_feature(acc, ARM_FEATURE_V5); + set_class_feature(acc, ARM_FEATURE_XSCALE); + acc->midr = 0x69052d05; + acc->ctr = 0xd172172; + acc->reset_sctlr = 0x00000078; } -static void pxa262_class_init(ARMCPUClass *cpu) +static void pxa262_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "marvell,xscale"; - set_class_feature(cpu, ARM_FEATURE_V5); - set_class_feature(cpu, ARM_FEATURE_XSCALE); - cpu->midr = 0x69052d06; - cpu->ctr = 0xd172172; - cpu->reset_sctlr = 0x00000078; + acc->dtb_compatible = "marvell,xscale"; + set_class_feature(acc, ARM_FEATURE_V5); + set_class_feature(acc, ARM_FEATURE_XSCALE); + acc->midr = 0x69052d06; + acc->ctr = 0xd172172; + acc->reset_sctlr = 0x00000078; } -static void pxa270a0_class_init(ARMCPUClass *cpu) +static void pxa270a0_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = 0x69054110; - cpu->ctr = 0xd172172; - cpu->reset_sctlr = 0x00000078; + acc->dtb_compatible = "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 = 0x69054110; + acc->ctr = 0xd172172; + acc->reset_sctlr = 0x00000078; } -static void pxa270a1_class_init(ARMCPUClass *cpu) +static void pxa270a1_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = 0x69054111; - cpu->ctr = 0xd172172; - cpu->reset_sctlr = 0x00000078; + acc->dtb_compatible = "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 = 0x69054111; + acc->ctr = 0xd172172; + acc->reset_sctlr = 0x00000078; } -static void pxa270b0_class_init(ARMCPUClass *cpu) +static void pxa270b0_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = 0x69054112; - cpu->ctr = 0xd172172; - cpu->reset_sctlr = 0x00000078; + acc->dtb_compatible = "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 = 0x69054112; + acc->ctr = 0xd172172; + acc->reset_sctlr = 0x00000078; } -static void pxa270b1_class_init(ARMCPUClass *cpu) +static void pxa270b1_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = 0x69054113; - cpu->ctr = 0xd172172; - cpu->reset_sctlr = 0x00000078; + acc->dtb_compatible = "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 = 0x69054113; + acc->ctr = 0xd172172; + acc->reset_sctlr = 0x00000078; } -static void pxa270c0_class_init(ARMCPUClass *cpu) +static void pxa270c0_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = 0x69054114; - cpu->ctr = 0xd172172; - cpu->reset_sctlr = 0x00000078; + acc->dtb_compatible = "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 = 0x69054114; + acc->ctr = 0xd172172; + acc->reset_sctlr = 0x00000078; } -static void pxa270c5_class_init(ARMCPUClass *cpu) +static void pxa270c5_class_init(ARMCPUClass *acc) { - cpu->dtb_compatible = "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 = 0x69054117; - cpu->ctr = 0xd172172; - cpu->reset_sctlr = 0x00000078; + acc->dtb_compatible = "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 = 0x69054117; + acc->ctr = 0xd172172; + acc->reset_sctlr = 0x00000078; } #ifdef CONFIG_TCG @@ -1010,51 +1010,51 @@ static void arm_v7m_class_init(ObjectClass *oc, void *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 = "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 = 0x411fd070; - cpu->revidr = 0x00000000; - cpu->reset_fpsid = 0x41034070; - cpu->isar.mvfr0 = 0x10110222; - cpu->isar.mvfr1 = 0x12111111; - cpu->isar.mvfr2 = 0x00000043; - cpu->ctr = 0x8444c004; - cpu->reset_sctlr = 0x00c50838; - cpu->isar.id_pfr0 = 0x00000131; - cpu->isar.id_pfr1 = 0x00011011; - cpu->isar.id_dfr0 = 0x03010066; - cpu->id_afr0 = 0x00000000; - cpu->isar.id_mmfr0 = 0x10101105; - cpu->isar.id_mmfr1 = 0x40000000; - cpu->isar.id_mmfr2 = 0x01260000; - cpu->isar.id_mmfr3 = 0x02102211; - cpu->isar.id_isar0 = 0x02101110; - cpu->isar.id_isar1 = 0x13112111; - cpu->isar.id_isar2 = 0x21232042; - cpu->isar.id_isar3 = 0x01112131; - cpu->isar.id_isar4 = 0x00011142; - cpu->isar.id_isar5 = 0x00011121; - cpu->isar.id_isar6 = 0; - cpu->isar.dbgdidr = 0x3516d000; - cpu->isar.dbgdevid = 0x00110f13; - cpu->isar.dbgdevid1 = 0x2; - cpu->isar.reset_pmcr_el0 = 0x41013000; - cpu->clidr = 0x0a200023; - cpu->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */ - cpu->ccsidr[1] = 0x201fe012; /* 48KB L1 icache */ - cpu->ccsidr[2] = 0x70ffe07a; /* 2048KB L2 cache */ - define_cortex_a72_a57_a53_cp_reginfo(cpu); + acc->dtb_compatible = "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 = 0x411fd070; + acc->revidr = 0x00000000; + acc->reset_fpsid = 0x41034070; + acc->isar.mvfr0 = 0x10110222; + acc->isar.mvfr1 = 0x12111111; + acc->isar.mvfr2 = 0x00000043; + acc->ctr = 0x8444c004; + acc->reset_sctlr = 0x00c50838; + acc->isar.id_pfr0 = 0x00000131; + acc->isar.id_pfr1 = 0x00011011; + acc->isar.id_dfr0 = 0x03010066; + acc->id_afr0 = 0x00000000; + acc->isar.id_mmfr0 = 0x10101105; + acc->isar.id_mmfr1 = 0x40000000; + acc->isar.id_mmfr2 = 0x01260000; + acc->isar.id_mmfr3 = 0x02102211; + acc->isar.id_isar0 = 0x02101110; + acc->isar.id_isar1 = 0x13112111; + acc->isar.id_isar2 = 0x21232042; + acc->isar.id_isar3 = 0x01112131; + acc->isar.id_isar4 = 0x00011142; + acc->isar.id_isar5 = 0x00011121; + acc->isar.id_isar6 = 0; + acc->isar.dbgdidr = 0x3516d000; + acc->isar.dbgdevid = 0x00110f13; + acc->isar.dbgdevid1 = 0x2; + acc->isar.reset_pmcr_el0 = 0x41013000; + acc->clidr = 0x0a200023; + acc->ccsidr[0] = 0x701fe00a; /* 32KB L1 dcache */ + acc->ccsidr[1] = 0x201fe012; /* 48KB L1 icache */ + acc->ccsidr[2] = 0x70ffe07a; /* 2048KB L2 cache */ + define_cortex_a72_a57_a53_cp_reginfo(acc); - aa32_max_features(cpu); + aa32_max_features(acc); #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 = FIELD_DP32(cpu->isar.mvfr0, MVFR0, FPSHVEC, 1); + acc->isar.mvfr0 = FIELD_DP32(acc->isar.mvfr0, MVFR0, FPSHVEC, 1); #endif } #endif /* !TARGET_AARCH64 */ From patchwork Tue Jan 3 18:16:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638757 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1394439pvb; Tue, 3 Jan 2023 10:28:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXuBOYWObYPSJTXOtsTq+t1d2mIGAhL3kd1SkxHdDdQXbbjmi7ouHePNZJQXalnAxNJyYo66 X-Received: by 2002:a05:622a:991:b0:3a9:7ce2:4c53 with SMTP id bw17-20020a05622a099100b003a97ce24c53mr66809010qtb.51.1672770495492; Tue, 03 Jan 2023 10:28:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770495; cv=none; d=google.com; s=arc-20160816; b=jqg+U1034MtcqW7pwNhmBiYkgLOK6GSIvLHbhQq6flcSSop1GlVdaBILSWr09a5IWJ 323TH44csS4gYBwaaV3F6Fe63ksgMssXtky7V+PCSsWtBhjByyrr+bL//KaZaG08rhYF OkKRZnJ0OkSg3RGf0bvwKsRBhn8nKb7KPmyMomydMR2dgLgBM6L7AXuot0tUT3XmIk6u lMrv4ppdPcSaLV0nakQ045tn6gRgPawYcx5KpVFLSF0t4xQhg89GIrUALrqRPuz8+b3r cZGEOuxf4mkYQ4yKAhUUQpzLD8s4tMmBvEkuA7/r6fiJifelRf+5wAp12wJo/PCzHxOk Ryvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LAidI3WiD+zjwr6by+YYhTTuNMWH39p6ritGq9qXxUI=; b=XqxETLnPPVW9VOoyK4gqliPSZUWamnt1nzoD8QlUHRxvJlcmZr2TH8cJU/tDZxN3dR RwNek+qLUs1FiSIRz9aXR9/P43PsLl2KAKzCsXNLBTvRZ2jrOuRunf2GxMhcMwJTkmcN TIZDvvXro+pBX4p6K0uN/GxTWyuk3spYVPlhiez0NzXalhCV4rKArMoOVEwbKk1imEBP bqOpMM5e0ESwIDa7yHAELGy+V+htfoy81D+ySYOWlV+T7jyUZULKRhberZWdhUcgeBOp 8qypCLH3C+5Dy9Qg7fAQ23Au4Qp+tUSg6MVvmkO8gt8RtT9YYNvYWWYmPZ336AkY034R j/pA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kCyD9Mi7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id fb19-20020a05622a481300b003a8114ea4d9si16208127qtb.179.2023.01.03.10.28.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:28:15 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=kCyD9Mi7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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 = 0x00000070; } -static void sa1100_class_init(ARMCPUClass *acc) +static void strongarm_class_init(ARMCPUClass *acc) { - acc->dtb_compatible = "intel,sa1100"; set_class_feature(acc, ARM_FEATURE_STRONGARM); set_class_feature(acc, ARM_FEATURE_DUMMY_C15_REGS); - acc->midr = 0x4401A11B; acc->reset_sctlr = 0x00000070; } +static void sa1100_class_init(ARMCPUClass *acc) +{ + strongarm_class_init(acc); + acc->dtb_compatible = "intel,sa1100"; + acc->midr = 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 = 0x6901B119; - acc->reset_sctlr = 0x00000070; } static void pxa250_class_init(ARMCPUClass *acc) From patchwork Tue Jan 3 18:16:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638762 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1394586pvb; Tue, 3 Jan 2023 10:28:40 -0800 (PST) X-Google-Smtp-Source: AMrXdXuM5vau1F00xJaVmKvA7WiEhSQw69V9nLfKSe7p91dMTAmZS2m3zcVXz4LMffd62/QxBRPe X-Received: by 2002:ac8:43cd:0:b0:3a8:16a9:b343 with SMTP id w13-20020ac843cd000000b003a816a9b343mr52990681qtn.48.1672770520246; Tue, 03 Jan 2023 10:28:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770520; cv=none; d=google.com; s=arc-20160816; b=VDjv1UHmp7SV9eaKHeWmBbFI+XtDWdfXtiio8RL5jFa7o4BAqlf/rH1DkaQ1MZA8iB QsF74M6FEWrNFlzssRiWNLk4FRfRr4qqX7H8xTSRPeilhChem0EgkgrLgAEYNFUgvtMp wWUjqXt+mQav8peon9N8dqDgHNZTP+3H5RcWiiQBW8Y/Cf4i0rQerHSk19AdqTsgXG9+ YmjcBi15pIt5Pes1KAs5V8xMjhYJr9HPfeFeW+/Bh2vnwbnEi+2IaNEjXEswFSo3Rg2I BilLF46Ou1nsxUFO5/N9zu3ZlvLcZ8+zhGamaQjwkycqvP7OnGh2irCw3o9nEWnc+rXO z4ng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=E2/QSQpKB1Wxz1OwWrj4zfmK4ONtqzkfez0TTluzjsI=; b=yT46ZIf5682w45iDnBJjSpe+rQAZ+iFwLFV4eVS6TCjxFLpxvrfZ/PGAQdJ1U1d9SX A5iQeH0y6EAOb6rtQxysVBGaN7QJf3wB5q0O6beEIvFwnOdtxO0wh08WWMZvESKj/3/b lecMFruXDNdOHPeI/Vqte6A0ELbhGtq2qbJG0xmbRrc9mTM+rwuv+J4BSEoc4aA3gdzq Ag0i2SQGB32UunytJUYwLktcQjKP9ngEZ1I7physkYWHj9ReW02reMYZcf2wK4taZnnm GDhu4v17EeQK5+leLH+1USBelVBE+lL35eAcXP2RpfxL6vKqaq0cpqZyMSGyBF1w9/xi +uUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UQgK1skC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id x62-20020a379541000000b006f9faedd088si15372456qkd.384.2023.01.03.10.28.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:28:40 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=UQgK1skC; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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 = 0x6901B119; } -static void pxa250_class_init(ARMCPUClass *acc) +static void xscale_class_init(ARMCPUClass *acc) { acc->dtb_compatible = "marvell,xscale"; set_class_feature(acc, ARM_FEATURE_V5); set_class_feature(acc, ARM_FEATURE_XSCALE); - acc->midr = 0x69052100; acc->ctr = 0xd172172; acc->reset_sctlr = 0x00000078; } +static void pxa250_class_init(ARMCPUClass *acc) +{ + xscale_class_init(acc); + acc->midr = 0x69052100; +} + static void pxa255_class_init(ARMCPUClass *acc) { - acc->dtb_compatible = "marvell,xscale"; - set_class_feature(acc, ARM_FEATURE_V5); - set_class_feature(acc, ARM_FEATURE_XSCALE); + xscale_class_init(acc); acc->midr = 0x69052d00; - acc->ctr = 0xd172172; - acc->reset_sctlr = 0x00000078; } static void pxa260_class_init(ARMCPUClass *acc) { - acc->dtb_compatible = "marvell,xscale"; - set_class_feature(acc, ARM_FEATURE_V5); - set_class_feature(acc, ARM_FEATURE_XSCALE); + xscale_class_init(acc); acc->midr = 0x69052903; - acc->ctr = 0xd172172; - acc->reset_sctlr = 0x00000078; } static void pxa261_class_init(ARMCPUClass *acc) { - acc->dtb_compatible = "marvell,xscale"; - set_class_feature(acc, ARM_FEATURE_V5); - set_class_feature(acc, ARM_FEATURE_XSCALE); + xscale_class_init(acc); acc->midr = 0x69052d05; - acc->ctr = 0xd172172; - acc->reset_sctlr = 0x00000078; } static void pxa262_class_init(ARMCPUClass *acc) { - acc->dtb_compatible = "marvell,xscale"; - set_class_feature(acc, ARM_FEATURE_V5); - set_class_feature(acc, ARM_FEATURE_XSCALE); + xscale_class_init(acc); acc->midr = 0x69052d06; - acc->ctr = 0xd172172; - acc->reset_sctlr = 0x00000078; +} + +static void xscale_iwmmxt_class_init(ARMCPUClass *acc) +{ + xscale_class_init(acc); + set_class_feature(acc, ARM_FEATURE_IWMMXT); } static void pxa270a0_class_init(ARMCPUClass *acc) { - acc->dtb_compatible = "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 = 0x69054110; - acc->ctr = 0xd172172; - acc->reset_sctlr = 0x00000078; } static void pxa270a1_class_init(ARMCPUClass *acc) { - acc->dtb_compatible = "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 = 0x69054111; - acc->ctr = 0xd172172; - acc->reset_sctlr = 0x00000078; } static void pxa270b0_class_init(ARMCPUClass *acc) { - acc->dtb_compatible = "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 = 0x69054112; - acc->ctr = 0xd172172; - acc->reset_sctlr = 0x00000078; } static void pxa270b1_class_init(ARMCPUClass *acc) { - acc->dtb_compatible = "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 = 0x69054113; - acc->ctr = 0xd172172; - acc->reset_sctlr = 0x00000078; } static void pxa270c0_class_init(ARMCPUClass *acc) { - acc->dtb_compatible = "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 = 0x69054114; - acc->ctr = 0xd172172; - acc->reset_sctlr = 0x00000078; } static void pxa270c5_class_init(ARMCPUClass *acc) { - acc->dtb_compatible = "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 = 0x69054117; - acc->ctr = 0xd172172; - acc->reset_sctlr = 0x00000078; } #ifdef CONFIG_TCG From patchwork Tue Jan 3 18:16:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638737 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1391710pvb; Tue, 3 Jan 2023 10:21:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXtPqWLcMvdHPSz59vMFLFf7hk4W7ylG1yx2y9I8hDnPHzTD1unSuIlPlmcCGOgnPoiUGZW6 X-Received: by 2002:ac8:47c7:0:b0:3a5:71a0:61fa with SMTP id d7-20020ac847c7000000b003a571a061famr63224504qtr.42.1672770065493; Tue, 03 Jan 2023 10:21:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770065; cv=none; d=google.com; s=arc-20160816; b=u/U+6q/D3x/OtjEQyyihtvPyFssE+dVVUsZNHifKXnZZhmmFYt1Pgj5uO2RO5QU06s 748nCLRbRB3zieUVSpCnAbA/xjKMBD5FjE4oW7KxCOXnTGtqHFodYjO9G453KVQTcZ7M sCYup6YMpHhfupBIX9pJGpEfT3Wgu42RNbttP0eNMo3Gri0CvUlGsDvgzGz3tRIS218L K2P8grii4CSRT+hsRfoLkv+YKU3lstLgnhDLlVOmBIt2jk466duvmz+lw3VPi/Z1r2R/ GSY7zD2HDHBExmUgNhL3K14ubA1duTgG8/ifJth6l0GZN3u2hyYmfe64XNwjwnYCsAlE kfoA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dBH2/umBb6PUIXvvI6VS3ET+RrQOEaWp5m0MqQjwqxU=; b=nB5HCYI1KYn3v448EDL7ur6YC0/RwwMfoRVUb6q6WTbW+wTS60rFMtYXi7aDQFDYy7 EA/6IFH79SRcLIfBcLmA1dE3JX/WnA5zwYX8n4kWkANKYF3LCL8Grlv7KFVwmmQaoDRl 28kQ9lTk4Iw7EVeBC49qKFr4haPFQ5u1wmC+dRxufHKJ9uddQjv5grwcicMgpYCalLdw ChcirdBxjsyrhIaveLuZ53Lk7KsoiqWM0ksXOT2VpmCZxhaLIXEkbWni6pg7M9JahU6s 8PY//o0J3E19ykGWZIsrDB+ehL3hJqxaX7LPwgGcXZo6F8G0Au2Dy7NTgIl7kymjxSOd UioA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="n/EpmBe8"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ge9-20020a05622a5c8900b0039cd8419b24si17189731qtb.384.2023.01.03.10.21.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:21:05 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="n/EpmBe8"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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=off. 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" /* 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]; }; 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; }; #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; /* 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 { 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[] = { 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() }; @@ -94,10 +92,6 @@ static Property sse200_properties[] = { 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() }; @@ -107,8 +101,6 @@ static Property sse300_properties[] = { 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() }; @@ -505,7 +497,7 @@ static const ARMSSEInfo armsse_variants[] = { { .name = TYPE_IOTKIT, .sse_version = ARMSSE_IOTKIT, - .cpu_type = ARM_CPU_TYPE_NAME("cortex-m33"), + .cpu_type[0] = ARM_CPU_TYPE_NAME("cortex-m33"), .sram_banks = 1, .sram_bank_base = 0x20000000, .num_cpus = 1, @@ -526,7 +518,31 @@ static const ARMSSEInfo armsse_variants[] = { { .name = TYPE_SSE200, .sse_version = ARMSSE_SSE200, - .cpu_type = ARM_CPU_TYPE_NAME("cortex-m33"), + .cpu_type[0] = ARM_CPU_TYPE_NAME("cortex-m33-nodsp-novfp"), + .cpu_type[1] = ARM_CPU_TYPE_NAME("cortex-m33"), + .sram_banks = 4, + .sram_bank_base = 0x20000000, + .num_cpus = 2, + .sys_version = 0x22041743, + .iidr = 0, + .cpuwait_rst = 2, + .has_mhus = true, + .has_cachectrl = true, + .has_cpusecctrl = true, + .has_cpuid = true, + .has_cpu_pwrctrl = false, + .has_sse_counter = false, + .has_tcms = false, + .props = sse200_properties, + .devinfo = sse200_devices, + .irq_is_common = sse200_irq_is_common, + }, + { + /* For Musca-B1, differs only on cpu[0]. */ + .name = TYPE_SSE200_B, + .sse_version = ARMSSE_SSE200, + .cpu_type[0] = ARM_CPU_TYPE_NAME("cortex-m33"), + .cpu_type[1] = ARM_CPU_TYPE_NAME("cortex-m33"), .sram_banks = 4, .sram_bank_base = 0x20000000, .num_cpus = 2, @@ -547,7 +563,7 @@ static const ARMSSEInfo armsse_variants[] = { { .name = TYPE_SSE300, .sse_version = ARMSSE_SSE300, - .cpu_type = ARM_CPU_TYPE_NAME("cortex-m55"), + .cpu_type[0] = ARM_CPU_TYPE_NAME("cortex-m55"), .sram_banks = 2, .sram_bank_base = 0x21000000, .num_cpus = 1, @@ -720,7 +736,8 @@ static void armsse_init(Object *obj) name = 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 = 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; - } - } 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 **errp) 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; - } - } /* * Tell the CPU where the NVIC is; it will fail realize if it doesn't @@ -528,8 +518,6 @@ static Property armv7m_properties[] = { 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(), }; 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 = clock_new(OBJECT(machine), "S32KCLK"); clock_set_hz(mms->s32kclk, S32KCLK_FRQ); + /* + * 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 == MUSCA_A ? TYPE_SSE200 : TYPE_SSE200_B); ssedev = 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 == 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); /* 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 = static Property arm_cpu_has_neon_property = DEFINE_PROP_BOOL("neon", ARMCPU, has_neon, true); -static Property arm_cpu_has_dsp_property = - DEFINE_PROP_BOOL("dsp", ARMCPU, has_dsp, true); - static Property arm_cpu_has_mpu_property = DEFINE_PROP_BOOL("has-mpu", ARMCPU, has_mpu, true); @@ -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 = true; - if (!kvm_enabled()) { + if (!kvm_enabled() && !arm_feature(&cpu->env, ARM_FEATURE_M)) { qdev_property_add_static(DEVICE(obj), &arm_cpu_has_vfp_property); } } @@ -1440,11 +1437,6 @@ static void arm_cpu_post_init(Object *obj) } } - 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, Error **errp) cpu->isar.mvfr1 = u; } - if (arm_feature(env, ARM_FEATURE_M) && !cpu->has_dsp) { - uint32_t u; - - unset_feature(env, ARM_FEATURE_THUMB_DSP); - - u = cpu->isar.id_isar1; - u = FIELD_DP32(u, ID_ISAR1, EXTEND, 1); - cpu->isar.id_isar1 = u; - - u = cpu->isar.id_isar2; - u = FIELD_DP32(u, ID_ISAR2, MULTU, 1); - u = FIELD_DP32(u, ID_ISAR2, MULTS, 1); - cpu->isar.id_isar2 = u; - - u = cpu->isar.id_isar3; - u = FIELD_DP32(u, ID_ISAR3, SIMD, 1); - u = FIELD_DP32(u, ID_ISAR3, SATURATE, 0); - cpu->isar.id_isar3 = 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 = 0x00000000; } +static void disable_m_dsp(ARMCPUClass *acc) +{ + uint32_t u; + + u = acc->isar.id_isar1; + u = FIELD_DP32(u, ID_ISAR1, EXTEND, 1); + acc->isar.id_isar1 = u; + + u = acc->isar.id_isar2; + u = FIELD_DP32(u, ID_ISAR2, MULTU, 1); + u = FIELD_DP32(u, ID_ISAR2, MULTS, 1); + acc->isar.id_isar2 = u; + + u = acc->isar.id_isar3; + u = FIELD_DP32(u, ID_ISAR3, SIMD, 1); + u = FIELD_DP32(u, ID_ISAR3, SATURATE, 0); + acc->isar.id_isar3 = u; + + unset_class_feature(acc, ARM_FEATURE_THUMB_DSP); +} + +static void disable_m_vfp(ARMCPUClass *acc) +{ + acc->isar.mvfr0 = 0; + acc->isar.mvfr1 = 0; + acc->isar.mvfr2 = 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 = 0x00000000; } +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 = 0x00000000; } +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 = 0x8000c000; } +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 = 0x8303c003; } +static void cortex_m55_nf_class_init(ARMCPUClass *acc) +{ + cortex_m55_class_init(acc); + disable_m_vfp(acc); +} + static const ARMCPRegInfo cortexr5_cp_reginfo[] = { /* Dummy the TCM region regs for the moment */ { .name = "ATCM", .cp = 15, .opc1 = 0, .crn = 9, .crm = 1, .opc2 = 0, @@ -1081,10 +1146,26 @@ static const ARMCPUInfo arm_tcg_cpus[] = { static const ARMCPUInfo arm_v7m_tcg_cpus[] = { { .name = "cortex-m0", .class_init = cortex_m0_class_init }, { .name = "cortex-m3", .class_init = cortex_m3_class_init }, + { .name = "cortex-m4", .class_init = cortex_m4_class_init }, + { .name = "cortex-m4-novfp", + .class_init = cortex_m4_nf_class_init }, + { .name = "cortex-m7", .class_init = cortex_m7_class_init }, + { .name = "cortex-m7-novfp", + .class_init = cortex_m7_nf_class_init }, + { .name = "cortex-m33", .class_init = cortex_m33_class_init }, + { .name = "cortex-m33-nodsp", + .class_init = cortex_m33_nd_class_init }, + { .name = "cortex-m33-novfp", + .class_init = cortex_m33_nf_class_init }, + { .name = "cortex-m33-nodsp-novfp", + .class_init = cortex_m33_ndnf_class_init }, + { .name = "cortex-m55", .class_init = cortex_m55_class_init }, + { .name = "cortex-m55-novfp", + .class_init = cortex_m55_nf_class_init }, }; static const TypeInfo arm_v7m_cpu_type_info = { From patchwork Tue Jan 3 18:16:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638748 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1393072pvb; Tue, 3 Jan 2023 10:24:47 -0800 (PST) X-Google-Smtp-Source: AMrXdXtnm+FUbRak9ijPA3yZRAE1bOaslc+NIl0EY4/3EfKssnRVqF/hpqmcTiVrZ5jAA+E3ZyRR X-Received: by 2002:a05:622a:4d98:b0:3a5:24ac:a175 with SMTP id ff24-20020a05622a4d9800b003a524aca175mr68083528qtb.56.1672770287548; Tue, 03 Jan 2023 10:24:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770287; cv=none; d=google.com; s=arc-20160816; b=DmqJYWFH9b5RQbY+RTpy3AZ3frU983WdFsh9PMbeYHT3cclJPq97eHpZdjSRFDuigR awF1BO8pPr8U7VzJIt5Js1yBMz305tDfAyhaIPfu3+9YwO/R4ZHOmADIrvYDySeF/vUr 2NJp/VI3TXElaUDStC11UXGBURyKOXKHTp8ADNM8mzUlJYr9WP1eG8x7eMqnV8cPYwVc rdnypm5q5QbZi0fmPQkVo0Hc15hz5pKQsnxJNnrAF2Wp94C1bdGbQRQWP6gv2WBv+Jaf Hiyrav769ExgeQyFFhH4UirLL5GupxvuXaAo5ZEznPj5Q8rtqvZZRgLmoS4kCwYphS3t HcIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=dszATuIwttfYWieXQT1KqRjch1JsKTu3HotiKgzPAys=; b=scqYEHZTwxMl0TSc7V1xxCMPV+DUeI/tCFb7Wjer+zMvjrLtoHIP+yLinIaW7PlEAK i8NBUQikCBJYQvjlMCTFDw476OOocBgJxna2PQnPqzMZyqBOWv0qvi+llRltWEtDW07w C0NVR4YTsMSDqg9dYtVRZeu9jX75QiXa3uZmAvEUgSjlARomVGc8kKp34TjR10f7q59h ehPC0PtExFb02AbuwbbvAjEuAmrblQ+CkZjY+xbSkUlfVC4tyqQ478R5MfuXCci+ulVr 0nL8LuzfYgCJQECVU5BjUywHll810arLVgn9ouk5onvZP1nRSIQ6T0xyOJfzdYL5s/0M /2RQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T5+n9k2F; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id ff16-20020a05622a4d9000b003a6a4b9c4cesi17783589qtb.202.2023.01.03.10.24.47 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:24:47 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=T5+n9k2F; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 = ARM_CPU(obj); - /* 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 = &cpu->env; int pagebits; Error *local_err = NULL; - bool no_aa32 = false; #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, Error **errp) cpu->isar.mvfr1 = u; } - /* 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 = !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); + } } 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 = 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; } From patchwork Tue Jan 3 18:16:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638734 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1391284pvb; Tue, 3 Jan 2023 10:19:54 -0800 (PST) X-Google-Smtp-Source: AMrXdXtxUbWiNK7xhfCuuiGRCKa0pFDIoEjeRdVQX2+zbZM+aEbXu2qt2Kx/BzcYZbfPTnmP0FCJ X-Received: by 2002:a05:622a:489b:b0:3ab:7391:28b with SMTP id fc27-20020a05622a489b00b003ab7391028bmr51729973qtb.6.1672769994324; Tue, 03 Jan 2023 10:19:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672769994; cv=none; d=google.com; s=arc-20160816; b=BBxBlOeBm3vT/azVoaSDEqbLoORoU2On5n23sHs0SYByi8VYqu9auVzLNWLWz/Lm7q Tqo9Ebzyw2x4j+5a8p4eOyLr6dzlK9ozWphU8fyZ83CbohgQz9AJlC+42P5vqzUZBPqp jKTjpXBGfgCkQaoLmcGKoxv4NDnSTyBPklteIhklCg7bz4yNxO4wG37vcz8vbq9UYFv+ xaScvg3pAWQBZdvFKpXDrp73i02vI0Gj/ZthAz2w6obRt3y80sO71TnpziLraMIJh75l +TApisfx+DJmgKTd2+gE9sCFCUp0WMFeFyJYd93+6hfJAbTTkf1RlhtV6Tv7AmOD9A0f sX6A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=0vUlG5Ud9gfVE8ISNFj2vMxvaEfoXG4adPrIDOgAWpM=; b=Y7gHoZKN7nxaKXNQ3cgoDRC59MlcFE0Z8Vf56e5bOJ7lKlCmUHsfo7TvSapQ3calcp m3PZA6msn9CiUTVF5mgP6jPuEDTL5TIZfgt16bi4m8fkuL8Y0rpfMokclQK3F+G1QC9k 35i+wCqJfAy+v7xGHrrEViwqBGdDu2V0LERhMxREiQQz0Gj4GLH+kdCWSu3LpahL1+LK cGy4acQ6X5ASvfru/JWgifmpZBngqMxVcCgCUGA///CpaURRybslbeBhjsCMBpWB0Hd/ SZ+zSGElXgeqiw5gQpegOMMZ9BxA8ST4tv2QiTQv2XcZ+qw3A0kDESQa3DBCAZ1jRLN8 q3QA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qb5JqUdO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id cg10-20020a05622a408a00b003a51fd42972si17271374qtb.184.2023.01.03.10.19.54 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:19:54 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Qb5JqUdO; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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[] = { +static const char * const cpu_model_advertised_features[] = { "aarch64", "pmu", "sve", "sve128", "sve256", "sve384", "sve512", "sve640", "sve768", "sve896", "sve1024", "sve1152", "sve1280", @@ -159,7 +159,7 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type, } } - obj = object_new(object_class_get_name(oc)); + obj = object_new_with_class(oc); if (qdict_in) { Visitor *visitor; @@ -175,7 +175,10 @@ CpuModelExpansionInfo *qmp_query_cpu_model_expansion(CpuModelExpansionType type, i = 0; while ((name = cpu_model_advertised_features[i++]) != NULL) { if (qdict_get(qdict_in, name)) { - if (!object_property_set(obj, name, visitor, &err)) { + ClassProperty *cp = 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 = 0; while ((name = cpu_model_advertised_features[i++]) != NULL) { ObjectProperty *prop = object_property_find(obj, name); - if (prop) { - QObject *value; + QObject *value = NULL; + if (prop) { assert(prop->get); value = object_property_get_qobject(obj, name, &error_abort); + } else { + ClassProperty *cprop = class_property_find(oc, name); + if (cprop) { + assert(cprop->get); + value = class_property_get_qobject(oc, name, &error_abort); + } + } + if (value) { qdict_put_obj(qdict_out, name, value); } } From patchwork Tue Jan 3 18:16:38 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638744 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1392522pvb; Tue, 3 Jan 2023 10:23:16 -0800 (PST) X-Google-Smtp-Source: AMrXdXvAIelQ49cMwHlqdzXeGUrMnfhJAqY9cfD4FbL+S1FieqcmP3EKvVT4orcnS+SM4megmnmG X-Received: by 2002:a0c:fc06:0:b0:4c7:5c88:8f54 with SMTP id z6-20020a0cfc06000000b004c75c888f54mr60105184qvo.45.1672770196393; Tue, 03 Jan 2023 10:23:16 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770196; cv=none; d=google.com; s=arc-20160816; b=uyqOzj+UXFIyYB4BG9aEpz87kbCHxMZdsVYcHEth1kHd/O6rfv6L3PrGCy7i973dFL fwJcWO1BTnSMA6IXrl6SrrsB44RmGjFh6p64Q7Efeixw4qyumwSNeyw36Bmq2pv1w9Rh sSmQv2jEllgyamh9vMi9KzQeEg58tTFlDB1yI4jQMZbyg0auKdVe9McV8MeCMGSk9pix wJOQ1ku5sBRwCPtc6f5MMlTLWfPt7oucEUMjxngVThs3IyL0rSvXeiPwJdbhNkvMxkSN A8FUezHWLxh4234dDMBQ7w/HTRAaj2eOKYnW6jIQVNdAf0B5bGNMG12VHoy/qK4UwdYz 8o9A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=9dq2GNw8hTG6FuOywlRgnm7eV4dHAv+6eWtmKAnnuvM=; b=bc0TMm6NDTipO62ycpxwcHS5lGxXSKHNjBYNXXXTNvjN0bGrco8rxKZZSuPpskfQDd oxE9pRg6uEXOu2/vjFnCxPEYU5Yia4SrJmEzf2tmb++VR40q305Vwt2o+c6LGO1WOhut VoNWyIQcokxy0aDY71hskgYK4IyykW2en5uOQXlqRgQqCUP3pKtBJLUJypZ1RLqH8svv tQHwsWcjHE2SQWpINzqDTkETnLaEWCgLPRjL62jne7ORrl1yv4dZ70TywcXZKpgzQzuO sF4JOjX+q0ens0d2Hv0PB7CHpDFVHLZNcFMguhlJLPPUz68qSlHeBUnpmZ4p0bmT4cKf p3yg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ldD3932V; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id jk7-20020ad45d47000000b004c6d80080b0si8205084qvb.417.2023.01.03.10.23.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:23:16 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=ldD3932V; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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_addr, qemu_irq irq, static void zynq_init(MachineState *machine) { ZynqMachineState *zynq_machine = ZYNQ_MACHINE(machine); + ObjectClass *cpu_class; ARMCPU *cpu; MemoryRegion *address_space_mem = get_system_memory(); MemoryRegion *ocm_ram = g_new(MemoryRegion, 1); @@ -191,7 +192,11 @@ static void zynq_init(MachineState *machine) exit(EXIT_FAILURE); } - cpu = ARM_CPU(object_new(machine->cpu_type)); + cpu_class = object_class_by_name(machine->cpu_type); + + class_property_set_uint(cpu_class, "midr", ZYNQ_BOARD_MIDR, &error_fatal); + + cpu = ARM_CPU(object_new_with_class(cpu_class)); /* 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_fatal); } - 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 offset, 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 = 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 = acc->features; cpu->isar = acc->isar; - cpu->midr = acc->midr; cpu->ctr = acc->ctr; cpu->pmceid0 = acc->pmceid0; cpu->pmceid1 = acc->pmceid1; @@ -2120,7 +2119,6 @@ static void cpu_arm_get_mp_affinity(Object *obj, Visitor *v, const char *name, } static Property arm_cpu_properties[] = { - 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 = { }; #endif /* CONFIG_TCG */ +static bool arm_class_prop_uint64_ofs(ObjectClass *oc, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + ARMCPUClass *acc = ARM_CPU_CLASS(oc); + uintptr_t ofs = (uintptr_t)opaque; + uint64_t *ptr = (void *)acc + ofs; + + return visit_type_uint64(v, name, ptr, errp); +} + static void arm_cpu_class_init(ObjectClass *oc, void *data) { ARMCPUClass *acc = ARM_CPU_CLASS(oc); @@ -2220,6 +2229,11 @@ static void arm_cpu_class_init(ObjectClass *oc, void *data) */ acc->dtb_compatible = "qemu,unknown"; acc->kvm_target = 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)); } 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 = &cpu->env; + ARMCPUClass *acc = 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 = "VPIDR", .state = ARM_CP_STATE_AA32, .cp = 15, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0, .access = PL2_RW, .accessfn = access_el3_aa32ns, - .resetvalue = cpu->midr, + .resetvalue = acc->midr, .type = ARM_CP_ALIAS | ARM_CP_EL3_NO_EL2_C_NZ, .fieldoffset = offsetoflow32(CPUARMState, cp15.vpidr_el2) }, { .name = "VPIDR_EL2", .state = ARM_CP_STATE_AA64, .opc0 = 3, .opc1 = 4, .crn = 0, .crm = 0, .opc2 = 0, - .access = PL2_RW, .resetvalue = cpu->midr, + .access = PL2_RW, .resetvalue = acc->midr, .type = ARM_CP_EL3_NO_EL2_C_NZ, .fieldoffset = offsetof(CPUARMState, cp15.vpidr_el2) }, { .name = "VMPIDR", .state = ARM_CP_STATE_AA32, @@ -8106,7 +8108,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) */ { .name = "MIDR", .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = CP_ANY, - .access = PL1_R, .resetvalue = cpu->midr, + .access = PL1_R, .resetvalue = acc->midr, .writefn = arm_cp_write_ignore, .raw_writefn = raw_write, .readfn = midr_read, .fieldoffset = offsetof(CPUARMState, cp15.c0_cpuid), @@ -8131,16 +8133,16 @@ void register_cp_regs_for_features(ARMCPU *cpu) ARMCPRegInfo id_v8_midr_cp_reginfo[] = { { .name = "MIDR_EL1", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 0, .opc2 = 0, - .access = PL1_R, .type = ARM_CP_NO_RAW, .resetvalue = cpu->midr, + .access = PL1_R, .type = ARM_CP_NO_RAW, .resetvalue = acc->midr, .fieldoffset = offsetof(CPUARMState, cp15.c0_cpuid), .readfn = midr_read }, /* crn = 0 op1 = 0 crm = 0 op2 = 4,7 : AArch32 aliases of MIDR */ { .name = "MIDR", .type = ARM_CP_ALIAS | ARM_CP_CONST, .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 4, - .access = PL1_R, .resetvalue = cpu->midr }, + .access = PL1_R, .resetvalue = acc->midr }, { .name = "MIDR", .type = ARM_CP_ALIAS | ARM_CP_CONST, .cp = 15, .crn = 0, .crm = 0, .opc1 = 0, .opc2 = 7, - .access = PL1_R, .resetvalue = cpu->midr }, + .access = PL1_R, .resetvalue = acc->midr }, { .name = "REVIDR_EL1", .state = ARM_CP_STATE_BOTH, .opc0 = 3, .opc1 = 0, .crn = 0, .crm = 0, .opc2 = 6, .access = PL1_R, From patchwork Tue Jan 3 18:16:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638747 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1392785pvb; Tue, 3 Jan 2023 10:23:59 -0800 (PST) X-Google-Smtp-Source: AMrXdXvZmjVNHCfRKa3Ub/FhOhvjgpWW+EEX89m7USuVICykeVI3wgg4AOW6AaKAJGFPv0RlSPdm X-Received: by 2002:a05:6214:2dca:b0:531:c30c:1887 with SMTP id nc10-20020a0562142dca00b00531c30c1887mr14660743qvb.36.1672770239637; Tue, 03 Jan 2023 10:23:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770239; cv=none; d=google.com; s=arc-20160816; b=AzPivY5eW6az9vqeKkxL09Efjm/PXUzBRCl5GGHWSKwjS8H1PBL09zIZmOpJ/QP2Zp cwZyu9UTdG1pQ5NkDVMuGyBKnB5HjxVJ9wKSP+2Glt3rYufDMcNlQ3CVvFkkRyIzhCFK shw309JhULHNeLgw+6hkDTTH45msJGWU6L6x+S1HKnhknC77lWH/tdAcYhWV0ptpk5SK YT1A22W/UO9ci0Lhhnb1Eu+aa0NL0s9N2FT+IIRXAy+7PfnaBhYpRB6+L5QcCrhiqoBo vizsRd5EBllMqg5FK3Al5R3CQOC3CtUonj5wXIZQUt0UEwscVCY4KvEfaKf+YzAGCebr 42jQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AoAnTqEKYUyofNs53oxpjz0CHNCNiHX3yNW6NklBHxc=; b=nDvomoCfR46xZmIh6T3j0YDc39hoxNzPqhOcGqbHaDc24vYq72VDK1P8AMMp/LNaom GIQhitfp2XUqXbEKzqcRMJu30oxfMu3VVuoVru0DpgZgK1JLelEW492tRargl0DC5vWp JMnffAs3LcX51ZDLV3juHxXeb83LAGs3QPSq17pSL80oep2g1kl8l85bN5OSnW5LpNeG 2LMBpwHozUf1iza7ImdqjGsl6634mQGeijcCkzKTAAWYZBEYfbGIxGVDDbLvU34dQCg0 2RNllYDJ7ZFGRLMuFw1/Bpw7SdPcOhex6TuroiPI/HPmx+PNLc/HAbYeXB/8f6Qh+1bP 22Sw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A1OdUv5X; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id kd9-20020a056214400900b004bb8f468c4bsi15849405qvb.83.2023.01.03.10.23.59 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:23:59 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=A1OdUv5X; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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]; + /* 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 { ARMVQMap sve_vq; ARMVQMap sme_vq; - - /* Generic timer counter frequency, in Hz */ - uint64_t gt_cntfrq_hz; }; 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 = ASPEED_SOC(obj); AspeedSoCClass *sc = 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(); } + cpu_class = object_class_by_name(sc->cpu_type); + class_property_set_uint(cpu_class, "cntfrq", 1125000000, &error_abort); + for (i = 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); - 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) } } -static Property arm_cpu_gt_cntfrq_property = - DEFINE_PROP_UINT64("cntfrq", ARMCPU, gt_cntfrq_hz, - NANOSECONDS_PER_SECOND / GTIMER_SCALE); - static Property arm_cpu_reset_cbar_property = DEFINE_PROP_UINT64("reset-cbar", ARMCPU, reset_cbar, 0); @@ -1342,6 +1338,12 @@ static void arm_set_pmu(Object *obj, bool value, Error **errp) unsigned int gt_cntfrq_period_ns(ARMCPU *cpu) { + ARMCPUClass *acc = 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 factor * 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); } static void arm_cpu_post_init(Object *obj) @@ -1466,10 +1468,6 @@ static void arm_cpu_post_init(Object *obj) qdev_property_add_static(DEVICE(obj), &arm_cpu_cfgend_property); - 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, Error **errp) } { - 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 = gt_cntfrq_period_ns(cpu); - } else { - scale = GTIMER_SCALE; - } + uint64_t scale = gt_cntfrq_period_ns(cpu); cpu->gt_timer[GTIMER_PHYS] = 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) acc->cp_regs = g_hash_table_new_full(g_direct_hash, g_direct_equal, NULL, g_free); + acc->gt_cntfrq_hz = NANOSECONDS_PER_SECOND / GTIMER_SCALE; acc->info = 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 */ } 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) } } +#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 = 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 *opaque) { ARMCPU *cpu = env_archcpu(env); + ARMCPUClass *acc = ARM_CPU_GET_CLASS(cpu); - cpu->env.cp15.c14_cntfrq = cpu->gt_cntfrq_hz; + cpu->env.cp15.c14_cntfrq = acc->gt_cntfrq_hz; } static const ARMCPRegInfo generic_timer_cp_reginfo[] = { From patchwork Tue Jan 3 18:16:40 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638735 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1391464pvb; Tue, 3 Jan 2023 10:20:24 -0800 (PST) X-Google-Smtp-Source: AMrXdXurmO+TPFOkItO+pI8AiC7Usj4X5NO2tHcf0+jOQ+CrpU4c3WTjn1yX+h5wn31j91NV4+Ku X-Received: by 2002:a05:622a:5a15:b0:3a7:ee3d:21b3 with SMTP id fy21-20020a05622a5a1500b003a7ee3d21b3mr76161700qtb.0.1672770024515; Tue, 03 Jan 2023 10:20:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770024; cv=none; d=google.com; s=arc-20160816; b=jGknsOgCX+By4qLperceXO1mPdlXgB5Xe/hymVdUJY9QxjsWSAdbkYt7/CzkHZ7jTp MRPnpfCjDwQJkfoHLOPoxwrdGmYzIK16ZQ643MbRgAPB3HYn9y2LFaYl4gD4TLoFnIzd YvtefhPuiWiVSP2QpfIUKH5PJAmXBa0/+YPM/cDzvM/7ERmUnFUlVsBO/yH67jwQPTzA 256W9omyqDBslVOTD3fozfEn5yYuV1QDXzEJ8TiEopBv5wGpSvBv0dCY/pFObfZP/hD8 yP8GtLtwhL/NzaecmcGqnpNBzRTwO+tp3jNR7rBt5yMscwhvj4oLoOIeOcR5NYIP65Tj c18w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=aEB0nGrFaxYSQkHhsFi8mtdM2L5qlb+qHO4UJ4164dk=; b=O0AnyAifRMMUwZEza0wsX9l6mwkBIYPrEZrcjiXabdpfeGrDlvoxCLoDqbM2EXyQ/Q C8gf13n5+XkBegrvH1GtzUfbpUb+jrmQm1Htv/+2yIzwskjt40IxtV1aXlbpl46TmsWY hjPcF5cgislLvUx5A69gsRaSROV9DVEqkfz85nXCkODQooqisuHjUXXOfib0PnCOEjoo S5U4HNH84uOkzuGP+jcORq9agPZQ4nqNxcT5Vg47ZJKs98mHtUUOTOFG2NyBnQF2yqjV Ruf2vXSKPPfyOc5R8c8/TY3MsiJBU5RPOXeXAygu/0RJqRZVggYBKz/NjKzo5ww+w8lf Dp2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TlypqxXa; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e3-20020ac845c3000000b003a5f9a090easi16536624qto.182.2023.01.03.10.20.24 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:20:24 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=TlypqxXa; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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; /* * 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 = DIGIC(obj); + const char *cpu_type = ARM_CPU_TYPE_NAME("arm946"); + ObjectClass *cpu_class = object_class_by_name(cpu_type); int i; - 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); for (i = 0; i < DIGIC4_NB_TIMERS; i++) { g_autofree char *name = g_strdup_printf("timer[%d]", i); @@ -52,11 +56,6 @@ static void digic_realize(DeviceState *dev, Error **errp) SysBusDevice *sbd; int i; - 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 = NPCM7XX(obj); + const char *cpu_type = ARM_CPU_TYPE_NAME("cortex-a9"); + ObjectClass *cpu_class = object_class_by_name(cpu_type); int i; + class_property_set_bool(cpu_class, "reset-hivecs", true, &error_abort); + for (i = 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); } object_initialize_child(obj, "a9mpcore", &s->a9mpcore, TYPE_A9MPCORE_PRIV); @@ -466,8 +469,6 @@ static void npcm7xx_realize(DeviceState *dev, Error **errp) &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); /* 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, XlnxZynqMPState *s, s->boot_cpu_ptr = &s->rpu_cpu[i]; } - object_property_set_bool(OBJECT(&s->rpu_cpu[i]), "reset-hivecs", true, - &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 = MACHINE(qdev_get_machine()); XlnxZynqMPState *s = XLNX_ZYNQMP(obj); + const char *cpu_type; + ObjectClass *cpu_class; int i; int num_apus = MIN(ms->smp.cpus, XLNX_ZYNQMP_NUM_APU_CPUS); @@ -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); + cpu_type = ARM_CPU_TYPE_NAME("cortex-a53"); + cpu_class = object_class_by_name(cpu_type); + class_property_set_bool(cpu_class, "reset-hivecs", true, &error_abort); + for (i = 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); } 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 = DEFINE_PROP_UINT64("reset-cbar", ARMCPU, reset_cbar, 0); -static Property arm_cpu_reset_hivecs_property = - DEFINE_PROP_BOOL("reset-hivecs", ARMCPU, reset_hivecs, false); - #ifndef CONFIG_USER_ONLY static Property arm_cpu_has_el2_property = 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); } - if (!arm_feature(&cpu->env, ARM_FEATURE_M)) { - qdev_property_add_static(DEVICE(obj), &arm_cpu_reset_hivecs_property); - } - 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, Error **errp) return; } - if (cpu->reset_hivecs) { - cpu->reset_sctlr |= (1 << 13); - } - if (cpu->cfgend) { if (arm_feature(&cpu->env, ARM_FEATURE_V7)) { cpu->reset_sctlr |= SCTLR_EE; @@ -2169,6 +2158,39 @@ static bool arm_class_prop_uint64_ofs(ObjectClass *oc, Visitor *v, return visit_type_uint64(v, name, ptr, errp); } +#ifndef CONFIG_USER_ONLY +static bool arm_class_prop_set_sctlrbit(ObjectClass *oc, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + ARMCPUClass *acc = ARM_CPU_CLASS(oc); + uint32_t mask = (uintptr_t)opaque; + bool val; + + if (!visit_type_bool(v, name, &val, errp)) { + return false; + } + + if (val) { + acc->reset_sctlr |= mask; + } else { + acc->reset_sctlr &= ~mask; + } + return true; +} + +static bool arm_class_prop_get_sctlrbit(ObjectClass *oc, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + ARMCPUClass *acc = ARM_CPU_CLASS(oc); + uint32_t mask = (uintptr_t)opaque; + bool val = 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 = 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 */ } 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 */ /* Run some consistency checks for TCG. */ if (tcg_enabled()) { From patchwork Tue Jan 3 18:16:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638741 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1392092pvb; Tue, 3 Jan 2023 10:22:08 -0800 (PST) X-Google-Smtp-Source: AMrXdXvBBpQnxNMknzauyFTRwO8pwb7RAjSmInTYGbejCFBVKTHMfGu104/5gs+aS1Y9ZYshIpqd X-Received: by 2002:ad4:5f07:0:b0:4e8:595c:8009 with SMTP id fo7-20020ad45f07000000b004e8595c8009mr91436694qvb.24.1672770128515; Tue, 03 Jan 2023 10:22:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770128; cv=none; d=google.com; s=arc-20160816; b=ShtLaCKMQ4IQ94WlKQGxFDP/MLdKzAmNk8QmH6PHCi9hfe+VHZpiFlMbMr7gK7S0Io ah0brq27hPFtVjeFY9Ru8iLH4DmG0MqlbCSRp/DgQVMYG3HEAMWo7YRW6dmKhT2r87zT yANrQm+yw9Xt6zOMo5KeogSRA4x1ai2XjnP+/q5sfjHzR7G67aB33zT3BYBy3oE7+z+L SHS2Yr99L931F5zW1WwWdov9zYiOUzcbXfL5K1nnvN88FmZRrX8yA8JgePDUUn3XtBP3 qpE+LjUT2UV+nqsv5p4Or7n0M1LTrTlSRfqK+3LpgX2o16gIz4SEeCc7jtx2ZaEUmY5x NdSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=iCYu68/AsQJDDTxu6B7ticUbbeKteDS0WJXiIHlsiNQ=; b=oDroIUK8zyJtXdOIo9lmjO1d2osBid5lbzmETWWQ37MtPgW7Zsol+DytLMM88aOB4o wnVaSktQEBOfM4my4rVTcffOsLV4g55oUDr/hD7ND84UWhKGgeiy+hQVgSXTJBnU8JxW uwvkz1gjnW5+4vBGXHuB93etTtclQzV+LemMA6jyDFkydm0YGJCnFo708OkSTFDTvN2Z /M1xNQBypWfNHBDFlab3BUXnwnd8OwbuUjLtIp4xNp032zH65POq+hAfw2s4LjDbxOr5 d8JD9cFIQAsKNdIWWAx1Ip/un0HFwnBWeQN+P2RVDHwjXMfMEhhIZYjc3Fv9wkY9WpZN XJSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NYRXx+bK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 15-20020a05621420af00b004c71609b11esi16213036qvd.137.2023.01.03.10.22.08 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:22:08 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NYRXx+bK; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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 @@ #include "hw/core/cpu.h" #include "qom/object.h" +#include "qapi/qapi-types-common.h" struct arm_boot_info; @@ -182,6 +183,9 @@ struct ARMCPUClass { * QEMU_KVM_ARM_TARGET_NONE if the kernel doesn't support this CPU type. */ uint32_t kvm_target; + + /* CPU has virtualization extension */ + OnOffAuto has_el2; }; 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" /* 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; - /* 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, BlockBackend *blk) static void allwinner_h3_init(Object *obj) { AwH3State *s = AW_H3(obj); + const char *cpu_type = ARM_CPU_TYPE_NAME("cortex-a7"); + ObjectClass *cpu_class = object_class_by_name(cpu_type); s->memmap = allwinner_h3_memmap; + /* ??? This is the default for A7. */ + class_property_set_bool(cpu_class, "has_el2", true, &error_abort); + for (int i = 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); } object_initialize_child(obj, "gic", &s->gic, TYPE_ARM_GIC); @@ -244,7 +248,6 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp) /* 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); /* 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 *cpu_type, SysBusDevice *busdev; int n; unsigned int smp_cpus = ms->smp.cpus; + ObjectClass *cpu_class = object_class_by_name(cpu_type); + + if (!virt) { + class_property_set_bool(cpu_class, "has_el2", false, NULL); + } /* Create the actual CPUs */ for (n = 0; n < smp_cpus; n++) { @@ -216,11 +221,6 @@ static void init_cpus(MachineState *ms, const char *cpu_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); - } - } 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 = NULL; MemoryRegion *tag_sysmem = NULL; MemoryRegion *secure_tag_sysmem = NULL; + ObjectClass *cpu_class; int n, virt_max_cpus; bool firmware_loaded; bool aarch64 = true; @@ -2032,6 +2033,16 @@ static void machvirt_init(MachineState *machine) possible_cpus = mc->possible_cpu_arch_ids(machine); + assert(possible_cpus->len == max_cpus); + for (n = 0; n < max_cpus; n++) { + assert(strcmp(machine->cpu_type, possible_cpus->cpus[n].type) == 0); + } + + cpu_class = 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 = object_new(possible_cpus->cpus[0].type); + cpuobj = object_new_with_class(cpu_class); armcpu = ARM_CPU(cpuobj); pa_bits = arm_pamax(armcpu); @@ -2143,8 +2154,7 @@ static void machvirt_init(MachineState *machine) create_fdt(vms); - assert(possible_cpus->len == max_cpus); - for (n = 0; n < possible_cpus->len; n++) { + for (n = 0; n < max_cpus; n++) { Object *cpuobj; CPUState *cs; @@ -2152,7 +2162,7 @@ static void machvirt_init(MachineState *machine) break; } - cpuobj = object_new(possible_cpus->cpus[n].type); + cpuobj = object_new_with_class(cpu_class); object_property_set_int(cpuobj, "mp-affinity", possible_cpus->cpus[n].arch_id, NULL); @@ -2168,10 +2178,6 @@ static void machvirt_init(MachineState *machine) object_property_set_bool(cpuobj, "has_el3", false, NULL); } - 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 = ARM_CPU_TYPE_NAME("cortex-a53"); cpu_class = 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); for (i = 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) object_property_set_bool(OBJECT(&s->apu_cpu[i]), "has_el3", s->secure, NULL); - object_property_set_bool(OBJECT(&s->apu_cpu[i]), "has_el2", s->virt, - 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 = false; - Object *cpuobj; gicdev = 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 = OBJECT(qemu_get_cpu(0)); + Object *cpuobj = OBJECT(qemu_get_cpu(0)); + ObjectClass *cpucls = object_get_class(cpuobj); + has_el3 = 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 = object_property_find(cpuobj, "has_el2") && - object_property_get_bool(cpuobj, "has_el2", &error_abort); + has_el2 = class_property_get_bool(cpucls, "has_el2", NULL); qdev_prop_set_bit(gicdev, "has-virtualization-extensions", has_el2); } 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 = DEFINE_PROP_UINT64("reset-cbar", ARMCPU, reset_cbar, 0); #ifndef CONFIG_USER_ONLY -static Property arm_cpu_has_el2_property = - DEFINE_PROP_BOOL("has_el2", ARMCPU, has_el2, true); - static Property arm_cpu_has_el3_property = 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 if (arm_feature(&cpu->env, ARM_FEATURE_PMU)) { @@ -1818,10 +1811,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) ID_AA64PFR0, EL3, 0); } - 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 *oc, Visitor *v, } #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 = ARM_CPU_CLASS(oc); + uintptr_t ofs = (uintptr_t)opaque; + OnOffAuto *ptr = (void *)acc + ofs; + bool val = *ptr == 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 = ARM_CPU_CLASS(oc); + uintptr_t ofs = (uintptr_t)opaque; + OnOffAuto *ptr = (void *)acc + ofs; + bool val; + + if (visit_type_bool(v, name, &val, errp)) { + *ptr = 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_el2)); + } #endif /* !CONFIG_USER_ONLY */ } @@ -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 = (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 = FIELD_DP32(acc->isar.id_pfr1, ID_PFR1, + VIRTUALIZATION, 0); + acc->isar.id_aa64pfr0 = 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 */ /* Run some consistency checks for TCG. */ From patchwork Tue Jan 3 18:16:42 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638738 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1391708pvb; Tue, 3 Jan 2023 10:21:05 -0800 (PST) X-Google-Smtp-Source: AMrXdXuS0+FBoIpZpq7yp0bdwVi6SYkiiNUO6A9dMaFtCrkGxWp0wseObY2NsirxrQY441DhGzQ4 X-Received: by 2002:a67:8c4:0:b0:3aa:18ae:a788 with SMTP id 187-20020a6708c4000000b003aa18aea788mr20868619vsi.6.1672770065372; Tue, 03 Jan 2023 10:21:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770065; cv=none; d=google.com; s=arc-20160816; b=FCBq3IH+fJ/pAWoNZ4e93ac758VZnAcrZb2g6LNlVdhbb9OzJFELs/amVhLag6c7Tp pFmVXgq/Tk8VnsgWoyyel4Gj4OmiYJYwq9DQFWs8G0lzfBoxLI4MS9TJ7ZkFKzZtXcUc V1UOUhiMEHHxTzQAvHi0xPHRn1LZgag9Sv+flPInOENDwvovrtnI7yFuziATIBcnCUG0 6qpBtznkldDkkM3cezPH8q82FgbkTX/WEa+xo4XqYN5wQgXF8+XSx7HMkyzLWudjM1jM EXALXxMy7HoUOzxLzA/Mum7LFxehYa44OJmAAITz7E8d3T5+xVKhVKT4q2mDwg/G9G9+ lwFw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=cEjKn8qgsXWu9xhy89oOazfgxATFsGsm3Jhd9ukMHZ8=; b=JUYEfOl5ZJ3VEsPWhiQsNrDxo0As88FWyaEV29MvD5+DXBt19u6cw8YeYq+EAF2Vqd QSt/+Vq+4Lw5q2Tm84CxzYN31382inyENyCtnhLuAc5I2V2jqpqF8x0le46QpNEVHYHz ibIYBV1OZPDR4MBE79f+3lthhAJ3mro5G6Ftls176dwHca5gyJQHWS9WMu60xKu3jiQ3 GgoL3XLd6FQ+tzHRbhrAgRWZgBctNbeChdb6q0GSVREJOKRiGy2YXfKG3zGYM3KpCIFX +1+6T1Yi1n8ci+I7WnbssQeqJWhVv/+0I8izC6VW0CJM78q3EKAx/L5zZg9uxyhr2WwP 75Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qlKact7T; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 2-20020a370602000000b006fa2412eec6si15444546qkg.589.2023.01.03.10.21.05 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:21:05 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=qlKact7T; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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; + /* 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; - /* 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) s->memmap = allwinner_h3_memmap; + /* 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); for (int i = 0; i < AW_H3_NUM_CPUS; i++) { @@ -246,9 +248,6 @@ static void allwinner_h3_realize(DeviceState *dev, Error **errp) qdev_prop_set_bit(DEVICE(&s->cpus[i]), "start-powered-off", i > 0); - /* 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, Error **errp) Exynos4210State *s = EXYNOS4210_SOC(socdev); MemoryRegion *system_mem = get_system_memory(); SysBusDevice *busdev; + ObjectClass *cpu_class; DeviceState *dev, *uart[4], *pl330[3]; int i, n; - for (n = 0; n < EXYNOS4210_NCPUS; n++) { - Object *cpuobj = object_new(ARM_CPU_TYPE_NAME("cortex-a9")); + cpu_class = object_class_by_name(ARM_CPU_TYPE_NAME("cortex-a9")); - /* 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(cpuobj, "has_el3")) { - object_property_set_bool(cpuobj, "has_el3", false, &error_fatal); - } + /* + * 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 = 0; n < EXYNOS4210_NCPUS; n++) { + Object *cpuobj = object_new_with_class(cpu_class); s->cpu[n] = 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; - cpuobj = object_new(machine->cpu_type); + cpu_class = object_class_by_name(machine->cpu_type); - /* 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 = object_new_with_class(cpu_class); qdev_realize(DEVICE(cpuobj), NULL, &error_fatal); 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; class_property_set_bool(cpu_class, "reset-hivecs", true, &error_abort); + class_property_set_bool(cpu_class, "has_el3", false, &error_abort); for (i = 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); - /* 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 = g_new(MemoryRegion, 1); DeviceState *dev, *sysctl, *gpio2, *pl041; SysBusDevice *busdev; + ObjectClass *cpu_class; qemu_irq pic[64]; PCIBus *pci_bus = NULL; NICInfo *nd; @@ -115,22 +116,21 @@ static void realview_init(MachineState *machine, break; } - for (n = 0; n < smp_cpus; n++) { - Object *cpuobj = object_new(machine->cpu_type); + cpu_class = 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); - /* 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. - */ - if (object_property_find(cpuobj, "has_el3")) { - object_property_set_bool(cpuobj, "has_el3", false, &error_fatal); - } + for (n = 0; n < smp_cpus; n++) { + Object *cpuobj = object_new_with_class(cpu_class); if (is_pb && is_mpcore) { object_property_set_int(cpuobj, "reset-cbar", periphbase, &error_fatal); } - qdev_realize(DEVICE(cpuobj), NULL, &error_fatal); cpu_irq[n] = 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; static void versatile_init(MachineState *machine, int board_id) { + ObjectClass *cpu_class; Object *cpuobj; ARMCPU *cpu; MemoryRegion *sysmem = get_system_memory(); @@ -206,15 +207,16 @@ static void versatile_init(MachineState *machine, int board_id) exit(1); } - cpuobj = object_new(machine->cpu_type); + cpu_class = object_class_by_name(machine->cpu_type); - /* 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 = object_new_with_class(cpu_class); qdev_realize(DEVICE(cpuobj), NULL, &error_fatal); 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 *cpu_type, unsigned int smp_cpus = ms->smp.cpus; ObjectClass *cpu_class = object_class_by_name(cpu_type); + if (!secure) { + class_property_set_bool(cpu_class, "has_el3", false, NULL); + } if (!virt) { class_property_set_bool(cpu_class, "has_el2", false, NULL); } /* Create the actual CPUs */ for (n = 0; n < smp_cpus; n++) { - Object *cpuobj = object_new(cpu_type); - - if (!secure) { - object_property_set_bool(cpuobj, "has_el3", false, NULL); - } + Object *cpuobj = object_new_with_class(cpu_class); 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) } cpu_class = object_class_by_name(machine->cpu_type); + class_property_set_bool(cpu_class, "has_el3", vms->secure, &error_abort); if (!vms->virt) { class_property_set_bool(cpu_class, "has_el2", false, &error_abort); } @@ -2174,10 +2175,6 @@ static void machvirt_init(MachineState *machine) aarch64 &= object_property_get_bool(cpuobj, "aarch64", NULL); - 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) cpu_class = object_class_by_name(machine->cpu_type); - class_property_set_uint(cpu_class, "midr", ZYNQ_BOARD_MIDR, &error_fatal); - - cpu = 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_fatal); - } + class_property_set_bool(cpu_class, "has_el3", false, &error_abort); + class_property_set_uint(cpu_class, "midr", ZYNQ_BOARD_MIDR, &error_abort); + + cpu = ARM_CPU(object_new_with_class(cpu_class)); 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 = ARM_CPU_TYPE_NAME("cortex-a53"); cpu_class = 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); for (i = 0; i < num_apus; i++) { @@ -528,8 +529,6 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Error **errp) s->boot_cpu_ptr = &s->apu_cpu[i]; } - object_property_set_bool(OBJECT(&s->apu_cpu[i]), "has_el3", s->secure, - 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 = false; gicdev = DEVICE(&s->gic); @@ -66,9 +65,9 @@ static void a15mp_priv_realize(DeviceState *dev, Error **errp) */ Object *cpuobj = OBJECT(qemu_get_cpu(0)); ObjectClass *cpucls = object_get_class(cpuobj); + bool has_el3; - has_el3 = object_property_find(cpuobj, "has_el3") && - object_property_get_bool(cpuobj, "has_el3", &error_abort); + has_el3 = class_property_get_bool(cpucls, "has_el3", NULL); qdev_prop_set_bit(gicdev, "has-security-extensions", has_el3); /* 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; cpu0 = qemu_get_cpu(0); cpuobj = OBJECT(cpu0); + cpucls = 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 **errp) /* Make the GIC's TZ support match the CPUs. We assume that * either all the CPUs have TZ, or none do. */ - has_el3 = object_property_find(cpuobj, "has_el3") && - object_property_get_bool(cpuobj, "has_el3", &error_abort); + has_el3 = class_property_get_bool(cpucls, "has_el3", &error_abort); qdev_prop_set_bit(gicdev, "has-security-extensions", has_el3); 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 = DEFINE_PROP_UINT64("reset-cbar", ARMCPU, reset_cbar, 0); -#ifndef CONFIG_USER_ONLY -static Property arm_cpu_has_el3_property = - DEFINE_PROP_BOOL("has_el3", ARMCPU, has_el3, true); -#endif - static Property arm_cpu_cfgend_property = DEFINE_PROP_BOOL("cfgend", ARMCPU, cfgend, false); @@ -1377,11 +1372,6 @@ static void arm_cpu_post_init(Object *obj) #ifndef CONFIG_USER_ONLY if (arm_feature(&cpu->env, ARM_FEATURE_EL3)) { - /* Add the has_el3 state CPU property only if EL3 is allowed. This will - * prevent "has_el3" from existing on CPUs which cannot support EL3. - */ - 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, Error **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, Error **errp) } } - 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 = FIELD_DP32(cpu->isar.id_pfr1, ID_PFR1, SECURITY, 0); - cpu->isar.id_dfr0 = FIELD_DP32(cpu->isar.id_dfr0, ID_DFR0, COPSDBG, 0); - cpu->isar.id_aa64pfr0 = 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 = MACHINE(qdev_get_machine()); unsigned int smp_cpus = ms->smp.cpus; - bool has_secure = cpu->has_el3 || arm_feature(env, ARM_FEATURE_M_SECURITY); + bool has_secure = arm_feature(env, ARM_FEATURE_EL3) || + arm_feature(env, ARM_FEATURE_M_SECURITY); /* * 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_el2)); } + 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_el3)); + } #endif /* !CONFIG_USER_ONLY */ } @@ -2405,6 +2381,42 @@ static bool arm_cpu_class_late_init(ObjectClass *oc, Error **errp) default: g_assert_not_reached(); } + + if (acc->has_el3 == ON_OFF_AUTO_AUTO) { + if (tcg_enabled() || qtest_enabled()) { + acc->has_el3 = (arm_class_feature(acc, ARM_FEATURE_EL3) + ? ON_OFF_AUTO_ON : ON_OFF_AUTO_OFF); + } else { + acc->has_el3 = 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 = FIELD_DP32(acc->isar.id_pfr1, ID_PFR1, SECURITY, 0); + acc->isar.id_dfr0 = FIELD_DP32(acc->isar.id_dfr0, ID_DFR0, COPSDBG, 0); + acc->isar.id_aa64pfr0 = 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 */ /* Run some consistency checks for TCG. */ From patchwork Tue Jan 3 18:16:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638758 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1394442pvb; Tue, 3 Jan 2023 10:28:15 -0800 (PST) X-Google-Smtp-Source: AMrXdXtxkPitqJbePvssrOJ30Bwz6wmyvgV31JvFMSDJIg35fVJXgM3nxPu4HH1/v7daCBXZMBit X-Received: by 2002:ad4:5c6d:0:b0:531:b085:4482 with SMTP id i13-20020ad45c6d000000b00531b0854482mr31327122qvh.31.1672770495781; Tue, 03 Jan 2023 10:28:15 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770495; cv=none; d=google.com; s=arc-20160816; b=zdmoO5eLmlG6txZHc9yPM0cPhR/3cNr6bWP23r1Pq/1srdrAgP6sdaAiakkpEdQ/qU ZPvTa3qytAk8zcc4wa/WDG4hYfrIqEIjYV2x5euSHXww/aXP7OsUFcGGLw9pt2RMItIK 4c9oskSfoCEQHBmcnfIw9JglIGr4IUIrvFCewFdw0qVBLnhE2+EXl0f2Ist960uFs44y rj/OZ1YGDWEHyRgQ8OaemzngZvc2Kw3Y7b0etRcUm1N0Zd/KacjWxgL9hS//2qkvk85J iuh9kTrGbrC2U2zZHZZTfEKDiOiNqojaf4Ct3xpiXxw9pAy+qEp9LgxP5G+OqDm+ohXd jdog== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=RTwMqyhlkCLAE14wwdpweGikJKU6H9FwK5bch9gSJbk=; b=uL4RTxXLj/XL05qLCh0kol39jWSXdTv4zD6v8HMTtvwDOe1RjuMeA/QOwQc2xmFWSH /FoAQOlkxYCRZrV9AD4KykbyYWTAx2i3F2SjcG9ek+4ctoiigsdm3jQaE1yJpV17HrXF YJlurJWeljNwBRaDj5Pr+yT6u9S5OOoy0aMLX7oHNwUI3J4XBDc1txwOBDqNxbx81FTN cFbvmnfEulA5upbWsRt3vihoRyAk7Q/9yGKAueReVTJGldBCy9Ozpn6rjr6ENRBnsQcI UVgP/34E5kNEcdnZg2/yGFPY4uzm7ueBbFo0bWMmpdqMb+nOK7Y+ye85ZEB3L+4RBgca sEmQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Kr6/wqmj"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id r10-20020a0562140c8a00b004c6fde7f98csi15917408qvr.434.2023.01.03.10.28.15 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:28:15 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="Kr6/wqmj"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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é --- 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 */ - /* Whether the cfgend input is high (i.e. this CPU should reset into - * big-endian mode). This setting isn't used directly: instead it modifies - * 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; 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 = acc->revidr; cpu->id_afr0 = acc->id_afr0; cpu->reset_fpsid = acc->reset_fpsid; - cpu->reset_sctlr = acc->reset_sctlr; cpu->reset_auxcr = acc->reset_auxcr; cpu->pmsav7_dregion = acc->pmsav7_dregion; cpu->sau_sregion = acc->sau_sregion; @@ -1280,9 +1279,6 @@ static void arm_cpu_initfn(Object *obj) static Property arm_cpu_reset_cbar_property = DEFINE_PROP_UINT64("reset-cbar", ARMCPU, reset_cbar, 0); -static Property arm_cpu_cfgend_property = - DEFINE_PROP_BOOL("cfgend", ARMCPU, cfgend, false); - static Property arm_cpu_has_vfp_property = DEFINE_PROP_BOOL("vfp", ARMCPU, has_vfp, true); @@ -1442,8 +1438,6 @@ static void arm_cpu_post_init(Object *obj) &cpu->psci_conduit, OBJ_PROP_FLAG_READWRITE); - 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, Error **errp) return; } - if (cpu->cfgend) { - if (arm_feature(&cpu->env, ARM_FEATURE_V7)) { - cpu->reset_sctlr |= SCTLR_EE; - } else { - cpu->reset_sctlr |= 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) } #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 = PL3_RW, .raw_writefn = raw_write, .writefn = sctlr_write, .fieldoffset = offsetof(CPUARMState, cp15.sctlr_el[3]), - .resetvalue = cpu->reset_sctlr }, + .resetvalue = acc->reset_sctlr }, }; define_arm_cp_regs(cpu, el3_regs); @@ -8331,7 +8331,7 @@ void register_cp_regs_for_features(ARMCPU *cpu) .access = PL1_RW, .accessfn = access_tvm_trvm, .bank_fieldoffsets = { offsetof(CPUARMState, cp15.sctlr_s), offsetof(CPUARMState, cp15.sctlr_ns) }, - .writefn = sctlr_write, .resetvalue = cpu->reset_sctlr, + .writefn = sctlr_write, .resetvalue = acc->reset_sctlr, .raw_writefn = raw_write, }; if (arm_feature(env, ARM_FEATURE_XSCALE)) { From patchwork Tue Jan 3 18:16:44 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638743 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1392212pvb; Tue, 3 Jan 2023 10:22:27 -0800 (PST) X-Google-Smtp-Source: AMrXdXsdZvmtCQPMbuBD921KoQT9AcX4aFYNLRl2ctWdKKRGPXo+IStF2XbdOzfmsGZ461wgb+DC X-Received: by 2002:a05:6214:5a01:b0:4c7:4a36:9066 with SMTP id lu1-20020a0562145a0100b004c74a369066mr65835135qvb.8.1672770147527; Tue, 03 Jan 2023 10:22:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770147; cv=none; d=google.com; s=arc-20160816; b=ANLawc/qVCUHpOUDd1lMRb7KhuVlL7H7PgLBAFvbDHwmCsIB8JTEfBDaqCvhHaLYa9 n1FEqApu6LfMl0JZtSgOpznh/N3J+ShZQBPOCXnVGQdVNFKh71kYynABjROh90+9ZPUd 7kakvswj/HiD7SwqR3NBUnwd1BM0R3wl6daBBoUsHGBPHqscu3G7kqGgYybU4kcvxdvQ HmLW9NHuS0F28N/rrEe25SX+zsq75Fkzbwh8RZQsgXqAJbu2GSRAX3lXhnD6VOdVhmLp E+q6+XvoWF21LMZpPx8UU2wR5jnhieR4jknPudFKJ65aDT1MeyvPz743f88uay2VSks5 aiMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AkaW/qtvsCW7a76sQ3IuBy/9ulOGdfXEvrcn4pt2h3o=; b=FTfs4lChCoPAeSlXWbQbF2fy5LNjusn1FlDIX6o/9D+Vkuymy2xRYgQKifWMct2Cft jtVK9A/orYaI2iR1VWFVuskgICxpB11Cw5iEzkHQSPRTHWmNaugOnfP7U0EObVgGkY7x HugaYLVs31aEjGIPvLhOvdGvJoPF3FKuXJn6TvThG4bE6VeEh+GjfNqbZkV2/jJrlys2 CECnNDfhVGXNBt0TzACF+vEypEcqzeYKSDLbN9t2g4Aj5K75ZtuXFmhHylvKF3m9+n+1 JHqcnunLcmSttSi/kXR5c0lldlLzzMo+q9FVGtXFFUIDA5QiBPxQdpV54UXHg5y2kbHs SPgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="P7/SMwRc"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 2-20020a370602000000b006fa2412eec6si15446431qkg.589.2023.01.03.10.22.27 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:22:27 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="P7/SMwRc"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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; }; 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 { /* CPU has PMU (Performance Monitor Unit) */ bool has_pmu; - /* CPU has VFP */ - bool has_vfp; - /* CPU has Neon */ - bool has_neon; /* 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) cpu_class = 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); for (i = 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); - 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); 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 = DEFINE_PROP_UINT64("reset-cbar", ARMCPU, reset_cbar, 0); -static Property arm_cpu_has_vfp_property = - DEFINE_PROP_BOOL("vfp", ARMCPU, has_vfp, true); - -static Property arm_cpu_has_neon_property = - DEFINE_PROP_BOOL("neon", ARMCPU, has_neon, true); - static Property arm_cpu_has_mpu_property = DEFINE_PROP_BOOL("has-mpu", ARMCPU, has_mpu, true); @@ -1381,27 +1375,6 @@ static void arm_cpu_post_init(Object *obj) object_property_add_bool(obj, "pmu", arm_get_pmu, arm_set_pmu); } - /* - * 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 = true; - if (!kvm_enabled() && !arm_feature(&cpu->env, ARM_FEATURE_M)) { - qdev_property_add_static(DEVICE(obj), &arm_cpu_has_vfp_property); - } - } - - if (arm_feature(&cpu->env, ARM_FEATURE_NEON)) { - cpu->has_neon = true; - if (!kvm_enabled()) { - qdev_property_add_static(DEVICE(obj), &arm_cpu_has_neon_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)) { @@ -1603,137 +1576,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) return; } - if (arm_feature(env, ARM_FEATURE_AARCH64) && - cpu->has_vfp != 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 = cpu->isar.id_aa64isar1; - t = FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 0); - cpu->isar.id_aa64isar1 = t; - - t = cpu->isar.id_aa64pfr0; - t = FIELD_DP64(t, ID_AA64PFR0, FP, 0xf); - cpu->isar.id_aa64pfr0 = t; - - u = cpu->isar.id_isar6; - u = FIELD_DP32(u, ID_ISAR6, JSCVT, 0); - u = FIELD_DP32(u, ID_ISAR6, BF16, 0); - cpu->isar.id_isar6 = u; - - u = cpu->isar.mvfr0; - u = FIELD_DP32(u, MVFR0, FPSP, 0); - u = FIELD_DP32(u, MVFR0, FPDP, 0); - u = FIELD_DP32(u, MVFR0, FPDIVIDE, 0); - u = FIELD_DP32(u, MVFR0, FPSQRT, 0); - u = FIELD_DP32(u, MVFR0, FPROUND, 0); - if (!arm_feature(env, ARM_FEATURE_M)) { - u = FIELD_DP32(u, MVFR0, FPTRAP, 0); - u = FIELD_DP32(u, MVFR0, FPSHVEC, 0); - } - cpu->isar.mvfr0 = u; - - u = cpu->isar.mvfr1; - u = FIELD_DP32(u, MVFR1, FPFTZ, 0); - u = FIELD_DP32(u, MVFR1, FPDNAN, 0); - u = FIELD_DP32(u, MVFR1, FPHP, 0); - if (arm_feature(env, ARM_FEATURE_M)) { - u = FIELD_DP32(u, MVFR1, FP16, 0); - } - cpu->isar.mvfr1 = u; - - u = cpu->isar.mvfr2; - u = FIELD_DP32(u, MVFR2, FPMISC, 0); - cpu->isar.mvfr2 = u; - } - - if (!cpu->has_neon) { - uint64_t t; - uint32_t u; - - unset_feature(env, ARM_FEATURE_NEON); - - t = cpu->isar.id_aa64isar0; - t = FIELD_DP64(t, ID_AA64ISAR0, AES, 0); - t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 0); - t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 0); - t = FIELD_DP64(t, ID_AA64ISAR0, SHA3, 0); - t = FIELD_DP64(t, ID_AA64ISAR0, SM3, 0); - t = FIELD_DP64(t, ID_AA64ISAR0, SM4, 0); - t = FIELD_DP64(t, ID_AA64ISAR0, DP, 0); - cpu->isar.id_aa64isar0 = t; - - t = cpu->isar.id_aa64isar1; - t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 0); - t = FIELD_DP64(t, ID_AA64ISAR1, BF16, 0); - t = FIELD_DP64(t, ID_AA64ISAR1, I8MM, 0); - cpu->isar.id_aa64isar1 = t; - - t = cpu->isar.id_aa64pfr0; - t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 0xf); - cpu->isar.id_aa64pfr0 = t; - - u = cpu->isar.id_isar5; - u = FIELD_DP32(u, ID_ISAR5, AES, 0); - u = FIELD_DP32(u, ID_ISAR5, SHA1, 0); - u = FIELD_DP32(u, ID_ISAR5, SHA2, 0); - u = FIELD_DP32(u, ID_ISAR5, RDM, 0); - u = FIELD_DP32(u, ID_ISAR5, VCMA, 0); - cpu->isar.id_isar5 = u; - - u = cpu->isar.id_isar6; - u = FIELD_DP32(u, ID_ISAR6, DP, 0); - u = FIELD_DP32(u, ID_ISAR6, FHM, 0); - u = FIELD_DP32(u, ID_ISAR6, BF16, 0); - u = FIELD_DP32(u, ID_ISAR6, I8MM, 0); - cpu->isar.id_isar6 = u; - - if (!arm_feature(env, ARM_FEATURE_M)) { - u = cpu->isar.mvfr1; - u = FIELD_DP32(u, MVFR1, SIMDLS, 0); - u = FIELD_DP32(u, MVFR1, SIMDINT, 0); - u = FIELD_DP32(u, MVFR1, SIMDSP, 0); - u = FIELD_DP32(u, MVFR1, SIMDHP, 0); - cpu->isar.mvfr1 = u; - - u = cpu->isar.mvfr2; - u = FIELD_DP32(u, MVFR2, SIMDMISC, 0); - cpu->isar.mvfr2 = u; - } - } - - if (!cpu->has_neon && !cpu->has_vfp) { - uint64_t t; - uint32_t u; - - t = cpu->isar.id_aa64isar0; - t = FIELD_DP64(t, ID_AA64ISAR0, FHM, 0); - cpu->isar.id_aa64isar0 = t; - - t = cpu->isar.id_aa64isar1; - t = FIELD_DP64(t, ID_AA64ISAR1, FRINTTS, 0); - cpu->isar.id_aa64isar1 = t; - - u = cpu->isar.mvfr0; - u = FIELD_DP32(u, MVFR0, SIMDREG, 0); - cpu->isar.mvfr0 = u; - - /* Despite the name, this field covers both VFP and Neon */ - u = cpu->isar.mvfr1; - u = FIELD_DP32(u, MVFR1, SIMDFMAC, 0); - cpu->isar.mvfr1 = 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); } -#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; } +#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_el3)); } #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_vfp)); + } + 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_neon)); + } } static bool arm_cpu_class_late_init(ObjectClass *oc, Error **errp) { ARMCPUClass *acc = ARM_CPU_CLASS(oc); + uint64_t t; + uint32_t u; 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 */ + if (!arm_class_feature(acc, ARM_FEATURE_M)) { + if (acc->has_vfp == ON_OFF_AUTO_AUTO) { + acc->has_vfp = ((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 disabled", + current_accel_name()); + return false; + } + + t = acc->isar.id_aa64isar1; + t = FIELD_DP64(t, ID_AA64ISAR1, JSCVT, 0); + acc->isar.id_aa64isar1 = t; + + t = acc->isar.id_aa64pfr0; + t = FIELD_DP64(t, ID_AA64PFR0, FP, 0xf); + acc->isar.id_aa64pfr0 = t; + + u = acc->isar.id_isar6; + u = FIELD_DP32(u, ID_ISAR6, JSCVT, 0); + u = FIELD_DP32(u, ID_ISAR6, BF16, 0); + acc->isar.id_isar6 = u; + + u = acc->isar.mvfr0; + u = FIELD_DP32(u, MVFR0, FPSP, 0); + u = FIELD_DP32(u, MVFR0, FPDP, 0); + u = FIELD_DP32(u, MVFR0, FPDIVIDE, 0); + u = FIELD_DP32(u, MVFR0, FPSQRT, 0); + u = FIELD_DP32(u, MVFR0, FPROUND, 0); + u = FIELD_DP32(u, MVFR0, FPTRAP, 0); + u = FIELD_DP32(u, MVFR0, FPSHVEC, 0); + acc->isar.mvfr0 = u; + + u = acc->isar.mvfr1; + u = FIELD_DP32(u, MVFR1, FPFTZ, 0); + u = FIELD_DP32(u, MVFR1, FPDNAN, 0); + u = FIELD_DP32(u, MVFR1, FPHP, 0); + acc->isar.mvfr1 = u; + + u = acc->isar.mvfr2; + u = FIELD_DP32(u, MVFR2, FPMISC, 0); + acc->isar.mvfr2 = u; + break; + } + + if (acc->has_neon == ON_OFF_AUTO_AUTO) { + acc->has_neon = (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 disabled", + current_accel_name()); + return false; + } + + unset_class_feature(acc, ARM_FEATURE_NEON); + + t = acc->isar.id_aa64isar0; + t = FIELD_DP64(t, ID_AA64ISAR0, AES, 0); + t = FIELD_DP64(t, ID_AA64ISAR0, SHA1, 0); + t = FIELD_DP64(t, ID_AA64ISAR0, SHA2, 0); + t = FIELD_DP64(t, ID_AA64ISAR0, SHA3, 0); + t = FIELD_DP64(t, ID_AA64ISAR0, SM3, 0); + t = FIELD_DP64(t, ID_AA64ISAR0, SM4, 0); + t = FIELD_DP64(t, ID_AA64ISAR0, DP, 0); + acc->isar.id_aa64isar0 = t; + + t = acc->isar.id_aa64isar1; + t = FIELD_DP64(t, ID_AA64ISAR1, FCMA, 0); + t = FIELD_DP64(t, ID_AA64ISAR1, BF16, 0); + t = FIELD_DP64(t, ID_AA64ISAR1, I8MM, 0); + acc->isar.id_aa64isar1 = t; + + t = acc->isar.id_aa64pfr0; + t = FIELD_DP64(t, ID_AA64PFR0, ADVSIMD, 0xf); + acc->isar.id_aa64pfr0 = t; + + u = acc->isar.id_isar5; + u = FIELD_DP32(u, ID_ISAR5, AES, 0); + u = FIELD_DP32(u, ID_ISAR5, SHA1, 0); + u = FIELD_DP32(u, ID_ISAR5, SHA2, 0); + u = FIELD_DP32(u, ID_ISAR5, RDM, 0); + u = FIELD_DP32(u, ID_ISAR5, VCMA, 0); + acc->isar.id_isar5 = u; + + u = acc->isar.id_isar6; + u = FIELD_DP32(u, ID_ISAR6, DP, 0); + u = FIELD_DP32(u, ID_ISAR6, FHM, 0); + u = FIELD_DP32(u, ID_ISAR6, BF16, 0); + u = FIELD_DP32(u, ID_ISAR6, I8MM, 0); + acc->isar.id_isar6 = u; + + u = acc->isar.mvfr1; + u = FIELD_DP32(u, MVFR1, SIMDLS, 0); + u = FIELD_DP32(u, MVFR1, SIMDINT, 0); + u = FIELD_DP32(u, MVFR1, SIMDSP, 0); + u = FIELD_DP32(u, MVFR1, SIMDHP, 0); + acc->isar.mvfr1 = u; + + u = acc->isar.mvfr2; + u = FIELD_DP32(u, MVFR2, SIMDMISC, 0); + acc->isar.mvfr2 = u; + + if (acc->has_vfp == ON_OFF_AUTO_OFF) { + t = acc->isar.id_aa64isar0; + t = FIELD_DP64(t, ID_AA64ISAR0, FHM, 0); + acc->isar.id_aa64isar0 = t; + + t = acc->isar.id_aa64isar1; + t = FIELD_DP64(t, ID_AA64ISAR1, FRINTTS, 0); + acc->isar.id_aa64isar1 = t; + + u = acc->isar.mvfr0; + u = FIELD_DP32(u, MVFR0, SIMDREG, 0); + acc->isar.mvfr0 = u; + + /* Despite the name, this field covers both VFP and Neon */ + u = acc->isar.mvfr1; + u = FIELD_DP32(u, MVFR1, SIMDFMAC, 0); + acc->isar.mvfr1 = u; + } + break; + } + if (acc->has_vfp != 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 neither"); + return false; + } + } + /* Run some consistency checks for TCG. */ if (tcg_enabled()) { bool no_aa32 = arm_class_feature(acc, ARM_FEATURE_AARCH64) && From patchwork Tue Jan 3 18:16:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638740 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1392050pvb; Tue, 3 Jan 2023 10:22:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXueuL5ysez+u2rLsuWEAz2wHwtLM50e3vJQ3+VzmX0B4OvhaE5IuOPmiPtyBj3gqO1D5G2C X-Received: by 2002:a67:f24b:0:b0:3ce:5cb:6ca4 with SMTP id y11-20020a67f24b000000b003ce05cb6ca4mr4830169vsm.11.1672770122981; Tue, 03 Jan 2023 10:22:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770122; cv=none; d=google.com; s=arc-20160816; b=qQr6w2/W4poTpSO/WuSMkefOdgGmaUSyuDK969fQ4LXtCBcmePhRMRgOLJ8M/kH+sl j7+aUpcBd2n1y4MXWpLjdBbjWyw28EXa/lC6QE5NmocXQeOqWc70k4B/IZJw6+Ao7FEc gObyAoeIgxiJIPA5qfMR91sFe+XupaeTQy7/dO/8qr93jCCLnhagmJa2wyPBm6IWZtRL Tbz/ou2jnrtAbtHPc/FbLuW1/ijVZQ5hxf737PLIcwN0lg9WK6B2JsqtZOo6EQ9aNI4Z lCNCWybBW9s9MpI8qkiFSPbadA43k45shlzFSNNGxQc7HgduVXj2oxEAHD7PIE22MWRU tf3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XGZyyVJrORAvKbSeUKRUPp59hPckNE/NE/CsroPLC8I=; b=Lw+7MUfroBOyMmb2/F1ufKJ30G7ySYPEX3gBJGDwt91QKFK/EpAegTrwSXnDOLOIou uGr+XDZxFBloT2r2KTTTR79CyaEMLQ7H88zyiU8FBeSeXtsb1FR4uRf3gGBi6UfPDlsc txxhoQ/tVbHf+CVP82SFgt5GAW9Y2xDp+8rh234R03gR2TOy6/ZM5zZX3v8ubitUipx5 zdXuR2h8XzuOyeZeMDeJ++zz9znQabad+OT2mUVoG2/C1r/1qUZrxRldibARK6F67lOX AWHgdnmCpSS2LUxwZaEnTHX5vU0Bs+DFLnY1ByiEt7Ld+8yfdjcJYyzZov1QaxpU29/Y nWPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NHdHvaU7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id h16-20020a05620a401000b006eaef7c08f5si18405342qko.197.2023.01.03.10.22.02 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:22:02 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=NHdHvaU7; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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; }; 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; - /* 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 = DEFINE_PROP_UINT64("reset-cbar", ARMCPU, reset_cbar, 0); -static Property arm_cpu_has_mpu_property = - 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 = - 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 = 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); } - 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->idau, qdev_prop_allow_set_link_before_realize, @@ -1663,39 +1642,21 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) FIELD_DP64(cpu->isar.id_aa64dfr0, ID_AA64DFR0, PMSVER, 0); } - /* 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 = 0; - } - if (cpu->pmsav7_dregion == 0) { - cpu->has_mpu = false; - } - - if (arm_feature(env, ARM_FEATURE_PMSA) && - arm_feature(env, ARM_FEATURE_V7)) { + if (cpu->pmsav7_dregion) { uint32_t nr = cpu->pmsav7_dregion; - 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] = g_new0(uint32_t, nr); - env->pmsav8.rlar[M_REG_NS] = g_new0(uint32_t, nr); - if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { - env->pmsav8.rbar[M_REG_S] = g_new0(uint32_t, nr); - env->pmsav8.rlar[M_REG_S] = g_new0(uint32_t, nr); - } - } else { - env->pmsav7.drbar = g_new0(uint32_t, nr); - env->pmsav7.drsr = g_new0(uint32_t, nr); - env->pmsav7.dracr = g_new0(uint32_t, nr); + if (arm_feature(env, ARM_FEATURE_V8)) { + /* PMSAv8 */ + env->pmsav8.rbar[M_REG_NS] = g_new0(uint32_t, nr); + env->pmsav8.rlar[M_REG_NS] = g_new0(uint32_t, nr); + if (arm_feature(env, ARM_FEATURE_M_SECURITY)) { + env->pmsav8.rbar[M_REG_S] = g_new0(uint32_t, nr); + env->pmsav8.rlar[M_REG_S] = g_new0(uint32_t, nr); } + } else { + env->pmsav7.drbar = g_new0(uint32_t, nr); + env->pmsav7.drsr = g_new0(uint32_t, nr); + env->pmsav7.dracr = g_new0(uint32_t, nr); } } @@ -1933,6 +1894,28 @@ static const struct TCGCPUOps arm_tcg_ops = { }; #endif /* CONFIG_TCG */ +static bool arm_class_prop_bool_ofs(ObjectClass *oc, Visitor *v, + const char *name, void *opaque, + Error **errp) +{ + ARMCPUClass *acc = ARM_CPU_CLASS(oc); + uintptr_t ofs = (uintptr_t)opaque; + bool *ptr = (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 = ARM_CPU_CLASS(oc); + uintptr_t ofs = (uintptr_t)opaque; + uint32_t *ptr = (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_neon)); } + + if (arm_class_feature(acc, ARM_FEATURE_PMSA)) { + acc->has_mpu = 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_mpu)); + + 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)); + } + } } 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) } } + /* + * 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 = 0; + } + if (acc->pmsav7_dregion == 0) { + acc->has_mpu = 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 = 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 ARMCPRegInfo *ri, uint64_t value) { ARMCPU *cpu = env_archcpu(env); + ARMCPUClass *acc = ARM_CPU_GET_CLASS(cpu); - 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 &= ~SCTLR_M; } From patchwork Tue Jan 3 18:16:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Henderson X-Patchwork-Id: 638761 Delivered-To: patch@linaro.org Received: by 2002:a17:522:f3c4:b0:4b4:3859:abed with SMTP id in4csp1394500pvb; Tue, 3 Jan 2023 10:28:26 -0800 (PST) X-Google-Smtp-Source: AMrXdXs/TusBpiVs1yRaar4aWzIWWA2252VIX/ASJBzlTEbf5gkxc0WHWMIuVx6sK7SujAfniGwx X-Received: by 2002:ac8:7152:0:b0:3a5:258c:d6a5 with SMTP id h18-20020ac87152000000b003a5258cd6a5mr62964754qtp.12.1672770506686; Tue, 03 Jan 2023 10:28:26 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672770506; cv=none; d=google.com; s=arc-20160816; b=R2mW6vysbOEsVCwTPOZqxuXUyLBLG8YuX1TURAQyssqPFJZLw1jae6WXIPTOYAxfqQ JMHtf8pPrPw1rE0EPMp2G1mxr7gmN4S2ziGsrVJQfsBYdBjKhK1Rf3L6LVFwlYM3QQpd xQaY5XizD4BV7pXIy0emD5eCjutmsL/t68X2kau1nBgIGsrvHZX/BBIiLXe7QEKNPoKX H9tfp+fGVrjuBrcpcGL9oo3ihoPKXOv43r29GICuXzVbKlcXwLQYe6GECGJrEBUjpZVy AT/LWRpfmyINQIieGRtHODRZKu6ApuVioNlBJgbNDeF62CWOJJW5fiqnhTj5O8LYTOPs kPAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=XMnuA3U8qCvAAKV0fJRhlFvw2qzRYQPSD0W9z7bDfCw=; b=FAbPzC811KtRr19ZlQ35r4GvCcJkIcSWebJeEKuxduhX+WvnaVaeoCAq5QO2zvVVQv S9Kbg3aPXCMB+ec6frHnKLVBACwcorVLfCJQOa0fQJ3/4iU0mGBOM3SFGDzSKc88F7oc V4L5XC39MjZYSdxRyOIc7GHP+fE2svcYGxiDDkW9Z/n2oaZs41UE/mN78Egeu+CR0a33 4Nmr3/RHwXNwdTTqJhdttdZ2omQoHSYCkKorCSg0CimK2EwfdRd+Zog5d7Gfpgms2JVb 1ggRDIF4SidLzF60ipsy30TJDhyV1VEReL46HydlHquo7MZ2EPQEMVq47dqmSq2dRhXF Z1nA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="rf/6yAwy"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id e17-20020ac86711000000b003a6a6aa0854si15780808qtp.582.2023.01.03.10.28.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 03 Jan 2023 10:28:26 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b="rf/6yAwy"; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 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) 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-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) 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) 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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org 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; /* 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; - /* 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); -/** - * 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; } -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 *vms) MachineState *ms = MACHINE(vms); if (!arm_feature(&armcpu->env, ARM_FEATURE_PMU)) { - assert(!object_property_get_bool(OBJECT(armcpu), "pmu", NULL)); return; } @@ -1951,9 +1950,11 @@ static void virt_cpu_post_init(VirtMachineState *vms, MemoryRegion *sysmem) int max_cpus = MACHINE(vms)->smp.max_cpus; bool aarch64, pmu, steal_time; CPUState *cpu; + ObjectClass *cpu_class; + cpu_class = object_get_class(OBJECT(first_cpu)); aarch64 = object_property_get_bool(OBJECT(first_cpu), "aarch64", NULL); - pmu = object_property_get_bool(OBJECT(first_cpu), "pmu", NULL); + pmu = class_property_get_bool(cpu_class, "pmu", NULL); steal_time = object_property_get_bool(OBJECT(first_cpu), "kvm-steal-time", NULL); @@ -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); + } /* * 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); } - 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 = DEFINE_PROP_UINT64("reset-cbar", ARMCPU, reset_cbar, 0); -static bool arm_get_pmu(Object *obj, Error **errp) -{ - ARMCPU *cpu = ARM_CPU(obj); - - return cpu->has_pmu; -} - -static void arm_set_pmu(Object *obj, bool value, Error **errp) -{ - ARMCPU *cpu = ARM_CPU(obj); - - if (value) { - if (kvm_enabled() && !kvm_arm_pmu_supported()) { - error_setg(errp, "'pmu' feature not supported by KVM on this host"); - return; - } - set_feature(&cpu->env, ARM_FEATURE_PMU); - } else { - unset_feature(&cpu->env, ARM_FEATURE_PMU); - } - cpu->has_pmu = value; -} - unsigned int gt_cntfrq_period_ns(ARMCPU *cpu) { ARMCPUClass *acc = ARM_CPU_GET_CLASS(cpu); @@ -1357,11 +1334,6 @@ static void arm_cpu_post_init(Object *obj) } #endif - if (arm_feature(&cpu->env, ARM_FEATURE_PMU)) { - cpu->has_pmu = 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->idau, qdev_prop_allow_set_link_before_realize, @@ -1586,9 +1558,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) return; } - if (!cpu->has_pmu) { - unset_feature(env, ARM_FEATURE_PMU); - } if (arm_feature(env, ARM_FEATURE_PMU)) { pmu_init(cpu); @@ -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_el3)); } + + 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_pmu)); + } #endif /* !CONFIG_USER_ONLY */ /* @@ -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 = (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 host", + current_accel_name()); + return false; + } + break; + default: + g_assert_not_reached(); + } #endif /* !CONFIG_USER_ONLY */ 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."); } -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 = KVM_ARM_VCPU_PMU_V3_INIT, }; - 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 = KVM_ARM_VCPU_PMU_V3_IRQ, }; - 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] |= 1 << KVM_ARM_VCPU_PMU_V3; pmu_supported = true; + } else { + /* This was optimistically set in aarch64_host_class_init. */ + unset_class_feature(acc, ARM_FEATURE_PMU); } 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 = ARM_CPU(cs); - CPUARMState *env = &cpu->env; uint64_t psciver; if (cpu->kvm_target == 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] |= 1 << KVM_ARM_VCPU_EL1_32BIT; } - if (!kvm_check_extension(cs->kvm_state, KVM_CAP_ARM_PMU_V3)) { - cpu->has_pmu = false; - } - if (cpu->has_pmu) { + if (arm_feature(&cpu->env, ARM_FEATURE_PMU)) { + assert(kvm_arm_pmu_supported()); cpu->kvm_init_features[0] |= 1 << KVM_ARM_VCPU_PMU_V3; - } else { - env->features &= ~(1ULL << ARM_FEATURE_PMU); } if (cpu_isar_feature(aa64_sve, cpu)) { assert(kvm_arm_sve_supported());