From nobody Sat May 18 05:05:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1713552413; cv=none; d=zohomail.com; s=zohoarc; b=jzmiATAvX8IX/NicX7GhaLUnU4wh8SQcuGmJVzj6ZqVbL8Tb6gohH/di0wvoGWHgehmkjek7YSU2yz3TMD8q4SiaZ8zdLTW9JBevUtNzA+q5gVE0e1TCFUPu1hnVJtoz7rrBBa4uKKks5Aw6VClByiJbcFKrLViJC1MWhS5/99c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713552413; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=bNLgiABY8b7+IQBpZ1mbekpvWukM6LJ8k/VAeslhvt8=; b=TzK+bXwM0rDFizcUTQWHQWQKQOwh/fSzbcs+i1QOWxGRUc05hkkwDbFD2bkDisuk4tnutuXiAtVcTODvkT4Rq0rnizqZNx68SisBd4FlVJJXIZjMIg+U3uPPGRIwDN9RSTodX7O2y/Z3mlxBR1v9QuwH3psJBKpeEfnhiHVIF2w= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713552413432599.8329325467926; Fri, 19 Apr 2024 11:46:53 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxtFd-00087m-8s; Fri, 19 Apr 2024 14:46:21 -0400 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 1rxtFX-00085x-QC for qemu-devel@nongnu.org; Fri, 19 Apr 2024 14:46:15 -0400 Received: from mail-wm1-x32a.google.com ([2a00:1450:4864:20::32a]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rxtFU-00011n-0P for qemu-devel@nongnu.org; Fri, 19 Apr 2024 14:46:15 -0400 Received: by mail-wm1-x32a.google.com with SMTP id 5b1f17b1804b1-418c0d83e61so24867255e9.3 for ; Fri, 19 Apr 2024 11:46:11 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id cs18-20020a056000089200b003437799a373sm5108718wrb.83.2024.04.19.11.46.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 11:46:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713552370; x=1714157170; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=bNLgiABY8b7+IQBpZ1mbekpvWukM6LJ8k/VAeslhvt8=; b=p6q9aGGT0OfnFggQs5ZYta0rltpIHgIHwf4/Zhe3OD5Bzar4AzY1I/GaJk+xOgdwOd oxMC3GiHt7n0YnmErIJeeqE082+G+RfoJU7X7mR0yQJQTBXhJwFVE6hPm1UlXIObQQFi X60Bb4Lfml9MuU5qZbMNliA8KMX2ZX5DOiOimi9yXO1FGL6X7YJg+JD3KVRWyh5TJjvW kdw88PkQah2kHo2ZwSvLblI++5w30G3V5t/kdPMD3cc2fdxgyo2yHD55M0iaUh+1mxSw nk9Yh0T/pqsxrNqPv/J6YH/dqAt4+v7ygmHaPeB+qhV57CEu3nN8GQZLoZsK2pe+fd/C xemw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713552370; x=1714157170; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=bNLgiABY8b7+IQBpZ1mbekpvWukM6LJ8k/VAeslhvt8=; b=Ey4m1Yw1ZRwzT/NVs1gO7c+TLMF7G2rkZgqFQ9cxY/MyTPSIF6MgByyAPLreaV5iMF cLJzNT9gJrEGeFPBYkDenyo4kMtPOAQnZk3JNuDDOZBusDivCOsKsLVV5lHwypnr6Bvl GH+gI/xAvvq34ASSwa6EAHBDGwUg+mltKawBxXS+TVEe5+kHP9rGjwdjXA7BUe/mqcJ2 YhcCzaxsjLNes6zPvsDWjtN4r1wW22XCyJRzi6waSu1UWvbz6h+RGNN34GUPhaFVvofY PJB/UWOy7cxOsIfwrf5NR0FFF0GR6UOzoT/rY9TvHZdCXOm3S2rpRJDIVecvGaelULpw i3eQ== X-Forwarded-Encrypted: i=1; AJvYcCUhJNT1wsG06Mz5z83DHIYwXyePjUTEt20l6t8PBwO1z4A31Umx//WtoubJnGk4lDup/A+bm5srMDATOZx83YJs3GsegMo= X-Gm-Message-State: AOJu0YzvAsLpvpnAPQ+x0buDlIHeWV35dUkHFq5d2EfrctNJXn9HRnlJ XMBFueVNg8THmHrzFIuYGKxgWL6ySHB9eYGL9pXWVoVYZjwK++qCPGmuRMKb4638fEhfYT6kcFw s X-Google-Smtp-Source: AGHT+IGkBQi1KoTbFiUXtUkdqkGKikvChTYHMGIgvN0Oszx5vIQZcazzMdXZPU7Gpd8wSutyhgtaPA== X-Received: by 2002:a05:600c:1f81:b0:418:5e80:a722 with SMTP id je1-20020a05600c1f8100b004185e80a722mr2224718wmb.24.1713552370303; Fri, 19 Apr 2024 11:46:10 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 1/3] hw: Add compat machines for 9.1 Date: Fri, 19 Apr 2024 19:46:06 +0100 Message-Id: <20240419184608.2675213-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240419184608.2675213-1-peter.maydell@linaro.org> References: <20240419184608.2675213-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::32a; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32a.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=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1713552413913100001 Content-Type: text/plain; charset="utf-8" From: Paolo Bonzini Add 9.1 machine types for arm/i440fx/m68k/q35/s390x/spapr. Cc: Cornelia Huck Cc: Thomas Huth Cc: Harsh Prateek Bora Cc: Gavin Shan Signed-off-by: Paolo Bonzini Acked-by: Thomas Huth Reviewed-by: Cornelia Huck Reviewed-by: Harsh Prateek Bora Reviewed-by: Zhao Liu [PMM: fixed the typos Zhao Liu found in the s390 changes] Signed-off-by: Peter Maydell --- include/hw/boards.h | 3 +++ include/hw/i386/pc.h | 3 +++ hw/arm/virt.c | 11 +++++++++-- hw/core/machine.c | 3 +++ hw/i386/pc.c | 3 +++ hw/i386/pc_piix.c | 17 ++++++++++++++--- hw/i386/pc_q35.c | 14 ++++++++++++-- hw/m68k/virt.c | 11 +++++++++-- hw/ppc/spapr.c | 17 ++++++++++++++--- hw/s390x/s390-virtio-ccw.c | 14 +++++++++++++- 10 files changed, 83 insertions(+), 13 deletions(-) diff --git a/include/hw/boards.h b/include/hw/boards.h index 8b8f6d5c00d..50e0cf4278e 100644 --- a/include/hw/boards.h +++ b/include/hw/boards.h @@ -425,6 +425,9 @@ struct MachineState { } \ type_init(machine_initfn##_register_types) =20 +extern GlobalProperty hw_compat_9_0[]; +extern const size_t hw_compat_9_0_len; + extern GlobalProperty hw_compat_8_2[]; extern const size_t hw_compat_8_2_len; =20 diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index 27a68071d77..349f79df086 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -198,6 +198,9 @@ void pc_system_parse_ovmf_flash(uint8_t *flash_ptr, siz= e_t flash_size); /* sgx.c */ void pc_machine_init_sgx_epc(PCMachineState *pcms); =20 +extern GlobalProperty pc_compat_9_0[]; +extern const size_t pc_compat_9_0_len; + extern GlobalProperty pc_compat_8_2[]; extern const size_t pc_compat_8_2_len; =20 diff --git a/hw/arm/virt.c b/hw/arm/virt.c index a9a913aeadb..c9119ef3847 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -3223,10 +3223,17 @@ static void machvirt_machine_init(void) } type_init(machvirt_machine_init); =20 -static void virt_machine_9_0_options(MachineClass *mc) +static void virt_machine_9_1_options(MachineClass *mc) { } -DEFINE_VIRT_MACHINE_AS_LATEST(9, 0) +DEFINE_VIRT_MACHINE_AS_LATEST(9, 1) + +static void virt_machine_9_0_options(MachineClass *mc) +{ + virt_machine_9_1_options(mc); + compat_props_add(mc->compat_props, hw_compat_9_0, hw_compat_9_0_len); +} +DEFINE_VIRT_MACHINE(9, 0) =20 static void virt_machine_8_2_options(MachineClass *mc) { diff --git a/hw/core/machine.c b/hw/core/machine.c index 37ede0e7d4f..a92bec23147 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -33,6 +33,9 @@ #include "hw/virtio/virtio-iommu.h" #include "audio/audio.h" =20 +GlobalProperty hw_compat_9_0[] =3D {}; +const size_t hw_compat_9_0_len =3D G_N_ELEMENTS(hw_compat_9_0); + GlobalProperty hw_compat_8_2[] =3D { { "migration", "zero-page-detection", "legacy"}, { TYPE_VIRTIO_IOMMU_PCI, "granule", "4k" }, diff --git a/hw/i386/pc.c b/hw/i386/pc.c index 5c21b0c4dbf..b0d818b2094 100644 --- a/hw/i386/pc.c +++ b/hw/i386/pc.c @@ -78,6 +78,9 @@ { "qemu64-" TYPE_X86_CPU, "model-id", "QEMU Virtual CPU version " v, }= ,\ { "athlon-" TYPE_X86_CPU, "model-id", "QEMU Virtual CPU version " v, }, =20 +GlobalProperty pc_compat_9_0[] =3D {}; +const size_t pc_compat_9_0_len =3D G_N_ELEMENTS(pc_compat_9_0); + GlobalProperty pc_compat_8_2[] =3D {}; const size_t pc_compat_8_2_len =3D G_N_ELEMENTS(pc_compat_8_2); =20 diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c index 18ba0766092..8850c49c66a 100644 --- a/hw/i386/pc_piix.c +++ b/hw/i386/pc_piix.c @@ -513,13 +513,26 @@ static void pc_i440fx_machine_options(MachineClass *m) "Use a different south bridge than PI= IX3"); } =20 -static void pc_i440fx_9_0_machine_options(MachineClass *m) +static void pc_i440fx_9_1_machine_options(MachineClass *m) { pc_i440fx_machine_options(m); m->alias =3D "pc"; m->is_default =3D true; } =20 +DEFINE_I440FX_MACHINE(v9_1, "pc-i440fx-9.1", NULL, + pc_i440fx_9_1_machine_options); + +static void pc_i440fx_9_0_machine_options(MachineClass *m) +{ + pc_i440fx_9_1_machine_options(m); + m->alias =3D NULL; + m->is_default =3D false; + + compat_props_add(m->compat_props, hw_compat_9_0, hw_compat_9_0_len); + compat_props_add(m->compat_props, pc_compat_9_0, pc_compat_9_0_len); +} + DEFINE_I440FX_MACHINE(v9_0, "pc-i440fx-9.0", NULL, pc_i440fx_9_0_machine_options); =20 @@ -528,8 +541,6 @@ static void pc_i440fx_8_2_machine_options(MachineClass = *m) PCMachineClass *pcmc =3D PC_MACHINE_CLASS(m); =20 pc_i440fx_9_0_machine_options(m); - m->alias =3D NULL; - m->is_default =3D false; =20 compat_props_add(m->compat_props, hw_compat_8_2, hw_compat_8_2_len); compat_props_add(m->compat_props, pc_compat_8_2, pc_compat_8_2_len); diff --git a/hw/i386/pc_q35.c b/hw/i386/pc_q35.c index c7bc8a2041f..6e1180d4b60 100644 --- a/hw/i386/pc_q35.c +++ b/hw/i386/pc_q35.c @@ -365,12 +365,23 @@ static void pc_q35_machine_options(MachineClass *m) pc_q35_compat_defaults, pc_q35_compat_defaults_len); } =20 -static void pc_q35_9_0_machine_options(MachineClass *m) +static void pc_q35_9_1_machine_options(MachineClass *m) { pc_q35_machine_options(m); m->alias =3D "q35"; } =20 +DEFINE_Q35_MACHINE(v9_1, "pc-q35-9.1", NULL, + pc_q35_9_1_machine_options); + +static void pc_q35_9_0_machine_options(MachineClass *m) +{ + pc_q35_9_1_machine_options(m); + m->alias =3D NULL; + compat_props_add(m->compat_props, hw_compat_9_0, hw_compat_9_0_len); + compat_props_add(m->compat_props, pc_compat_9_0, pc_compat_9_0_len); +} + DEFINE_Q35_MACHINE(v9_0, "pc-q35-9.0", NULL, pc_q35_9_0_machine_options); =20 @@ -378,7 +389,6 @@ static void pc_q35_8_2_machine_options(MachineClass *m) { PCMachineClass *pcmc =3D PC_MACHINE_CLASS(m); pc_q35_9_0_machine_options(m); - m->alias =3D NULL; m->max_cpus =3D 1024; compat_props_add(m->compat_props, hw_compat_8_2, hw_compat_8_2_len); compat_props_add(m->compat_props, pc_compat_8_2, pc_compat_8_2_len); diff --git a/hw/m68k/virt.c b/hw/m68k/virt.c index b8e5e102e6b..09bc9bdfefb 100644 --- a/hw/m68k/virt.c +++ b/hw/m68k/virt.c @@ -357,10 +357,17 @@ type_init(virt_machine_register_types) } \ type_init(machvirt_machine_##major##_##minor##_init); =20 -static void virt_machine_9_0_options(MachineClass *mc) +static void virt_machine_9_1_options(MachineClass *mc) { } -DEFINE_VIRT_MACHINE(9, 0, true) +DEFINE_VIRT_MACHINE(9, 1, true) + +static void virt_machine_9_0_options(MachineClass *mc) +{ + virt_machine_9_1_options(mc); + compat_props_add(mc->compat_props, hw_compat_9_0, hw_compat_9_0_len); +} +DEFINE_VIRT_MACHINE(9, 0, false) =20 static void virt_machine_8_2_options(MachineClass *mc) { diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index e9bc97fee08..36ada4d0baf 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -4806,14 +4806,25 @@ static void spapr_machine_latest_class_options(Mach= ineClass *mc) type_init(spapr_machine_register_##suffix) =20 /* - * pseries-9.0 + * pseries-9.1 */ -static void spapr_machine_9_0_class_options(MachineClass *mc) +static void spapr_machine_9_1_class_options(MachineClass *mc) { /* Defaults for the latest behaviour inherited from the base class */ } =20 -DEFINE_SPAPR_MACHINE(9_0, "9.0", true); +DEFINE_SPAPR_MACHINE(9_1, "9.1", true); + +/* + * pseries-9.0 + */ +static void spapr_machine_9_0_class_options(MachineClass *mc) +{ + spapr_machine_9_1_class_options(mc); + compat_props_add(mc->compat_props, hw_compat_9_0, hw_compat_9_0_len); +} + +DEFINE_SPAPR_MACHINE(9_0, "9.0", false); =20 /* * pseries-8.2 diff --git a/hw/s390x/s390-virtio-ccw.c b/hw/s390x/s390-virtio-ccw.c index b1dcb3857f0..7cebbf6c02a 100644 --- a/hw/s390x/s390-virtio-ccw.c +++ b/hw/s390x/s390-virtio-ccw.c @@ -859,14 +859,26 @@ bool css_migration_enabled(void) } = \ type_init(ccw_machine_register_##suffix) =20 +static void ccw_machine_9_1_instance_options(MachineState *machine) +{ +} + +static void ccw_machine_9_1_class_options(MachineClass *mc) +{ +} +DEFINE_CCW_MACHINE(9_1, "9.1", true); + static void ccw_machine_9_0_instance_options(MachineState *machine) { + ccw_machine_9_1_instance_options(machine); } =20 static void ccw_machine_9_0_class_options(MachineClass *mc) { + ccw_machine_9_1_class_options(mc); + compat_props_add(mc->compat_props, hw_compat_9_0, hw_compat_9_0_len); } -DEFINE_CCW_MACHINE(9_0, "9.0", true); +DEFINE_CCW_MACHINE(9_0, "9.0", false); =20 static void ccw_machine_8_2_instance_options(MachineState *machine) { --=20 2.34.1 From nobody Sat May 18 05:05:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1713552440; cv=none; d=zohomail.com; s=zohoarc; b=FjsEJV9a0GKWey/Oj48wAwEqMFbALx6BX0ojeix3OR6ko4aR4Ywh9FNki1LlNm0o1UPrAupufZuVEM8kMKig18S8TRtlnYxnKlGOwN+4tW+3qkOTvu8vUekgWd286X4w/K+FCQJB7aRwrwerHt/JoAceCNlPbkwmyvzDwnzvgNo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713552440; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=cD15Yu4sqNz4RqnI7YL4Ofu26geh4vOxHGToCiBD3jE=; b=kAkz1P5rWBWbo5A3tvwua+Wk51vIk+TWc1iy5CmBOl81PNALQMRkDMONnEq5h8I97BYPyn8SxtlaRpUdmziAqFXRDnX2EznEuMs9hyzBnqPts1cPDE7CDXiePjUJ35yPS4e51h9oCLbllGepLF/jc2F1dF9q0D8xQbaK8jW677g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713552440952214.31545877051997; Fri, 19 Apr 2024 11:47:20 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxtFc-00086z-Ad; Fri, 19 Apr 2024 14:46:20 -0400 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 1rxtFX-00085c-IQ for qemu-devel@nongnu.org; Fri, 19 Apr 2024 14:46:15 -0400 Received: from mail-wr1-x42b.google.com ([2a00:1450:4864:20::42b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rxtFU-00011z-K3 for qemu-devel@nongnu.org; Fri, 19 Apr 2024 14:46:15 -0400 Received: by mail-wr1-x42b.google.com with SMTP id ffacd0b85a97d-347c197a464so1623041f8f.2 for ; Fri, 19 Apr 2024 11:46:12 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id cs18-20020a056000089200b003437799a373sm5108718wrb.83.2024.04.19.11.46.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 11:46:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713552371; x=1714157171; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=cD15Yu4sqNz4RqnI7YL4Ofu26geh4vOxHGToCiBD3jE=; b=c04mI1x0RibMi2WGYX6R0ljpHHK217XENKr/ySn3LWJlZAwhzZGeAHdeOVmjnenIp0 23xSWR5IBEQlco5NDZdqAckocQpK5AkQGUAhK07L/BoUriF4mqfYKefax7knKD2hYdM1 IGpnC5WzIlM/tFgTlQr8Xq54ud603QWgLO2/CT0w75WHThi3XrL60gdaF29w3P4lOKro Kz33lK2FYKvUsR/tagNXEduyZ7lpeiqh6zur1VK5SdKxqEGvzqY/x616v4hq6X5r+rxx 1QN2BA6eoDSB7tOv7KDREUwTV1XHW/CGTqcn9jn8mq3qIV2wy/toLcy0OG//RECw9c+8 uKeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713552371; x=1714157171; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=cD15Yu4sqNz4RqnI7YL4Ofu26geh4vOxHGToCiBD3jE=; b=WXCd9ND7DSBjgE81QXKo4ue58CUlE11vujE5FFNp6zaUpmRuHEn1fFt0lXPf7sfL64 PaKpf8lgQnOBi3vzY10QD1PIK/61kZ6BUZg5XjR8BwGnOXvd+Pg6snZpV2zdUUhoP5r2 PnWPFEJpe+xa5ctymS76grJ5r+hUgHVDWIXmBExH7f246q067p5PNg2/9zaGreUrxIH+ sT99V8/SXvq5ZeJ0EDWj3zK7p3oTYtmJjLVJT4VhtvOgmmbNokSjyLljz0AXgxW/auEL Cr29oUPBIofXISYvYmm08NpJJ8U/wHBjaBdW7CeCRFWvR73w1u1/EzFlQY0HUzQJ4t9J iOhw== X-Forwarded-Encrypted: i=1; AJvYcCXoDhAOAHh3IathcwxFESlMFoBLucnJ9F1MMR5wt5I5e0gS59p6rd9DjEEPstILTcsWgetFlt4CP1KJnPWm7IGNJDs7fE4= X-Gm-Message-State: AOJu0YxUakRxy5EM9BGitMVfXkzsQdLEjK+1OWSZzd7JABxf4Mi5B/5U B9mqH1lPDOfUsZcFm1+sxUII2/MWV81vMWk8t5g0jbP2aJjSa25pkphs1Jsf6QaipBnCLnaAvFW o X-Google-Smtp-Source: AGHT+IHCSwRfMq5pElooAAoSAGIgEQVn/uZ7O8ErYgQdlPVrBGvxe+oJI+COXXpU5Qc/RVg9B/Pjow== X-Received: by 2002:adf:f6c3:0:b0:343:71c2:287e with SMTP id y3-20020adff6c3000000b0034371c2287emr1771485wrp.59.1713552370825; Fri, 19 Apr 2024 11:46:10 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 2/3] target/arm: Refactor default generic timer frequency handling Date: Fri, 19 Apr 2024 19:46:07 +0100 Message-Id: <20240419184608.2675213-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240419184608.2675213-1-peter.maydell@linaro.org> References: <20240419184608.2675213-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42b; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42b.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1713552442055100003 Content-Type: text/plain; charset="utf-8" The generic timer frequency is settable by board code via a QOM property "cntfrq", but otherwise defaults to 62.5MHz. The way this is done includes some complication resulting from how this was originally a fixed value with no QOM property. Clean it up: * always set cpu->gt_cntfrq_hz to some sensible value, whether the CPU has the generic timer or not, and whether it's system or user-only emulation * this means we can always use gt_cntfrq_hz, and never need the old GTIMER_SCALE define * set the default value in exactly one place, in the realize fn The aim here is to pave the way for handling the ARMv8.6 requirement that the generic timer frequency is always 1GHz. We're going to do that by having old CPU types keep their legacy-in-QEMU behaviour and having the default for any new CPU types be a 1GHz rather han 62.5MHz cntfrq, so we want the point where the default is decided to be in one place, and in code, not in a DEFINE_PROP_UINT64() initializer. This commit should have no behavioural changes. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- target/arm/internals.h | 7 ++++--- target/arm/cpu.c | 31 +++++++++++++++++-------------- target/arm/helper.c | 16 ++++++++-------- 3 files changed, 29 insertions(+), 25 deletions(-) diff --git a/target/arm/internals.h b/target/arm/internals.h index dd3da211a3f..74d4b1b0990 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -59,10 +59,11 @@ static inline bool excp_is_internal(int excp) || excp =3D=3D EXCP_SEMIHOST; } =20 -/* Scale factor for generic timers, ie number of ns per tick. - * This gives a 62.5MHz timer. +/* + * Default frequency for the generic timer, in Hz. + * This is 62.5MHz, which gives a 16 ns tick period. */ -#define GTIMER_SCALE 16 +#define GTIMER_DEFAULT_HZ 62500000 =20 /* Bit definitions for the v7M CONTROL register */ FIELD(V7M_CONTROL, NPRIV, 0, 1) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index ab8d007a86c..b248b283423 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1381,9 +1381,12 @@ static void arm_cpu_initfn(Object *obj) } } =20 +/* + * 0 means "unset, use the default value". That default might vary dependi= ng + * on the CPU type, and is set in the realize fn. + */ static Property arm_cpu_gt_cntfrq_property =3D - DEFINE_PROP_UINT64("cntfrq", ARMCPU, gt_cntfrq_hz, - NANOSECONDS_PER_SECOND / GTIMER_SCALE); + DEFINE_PROP_UINT64("cntfrq", ARMCPU, gt_cntfrq_hz, 0); =20 static Property arm_cpu_reset_cbar_property =3D DEFINE_PROP_UINT64("reset-cbar", ARMCPU, reset_cbar, 0); @@ -1829,6 +1832,17 @@ static void arm_cpu_realizefn(DeviceState *dev, Erro= r **errp) return; } =20 + if (!cpu->gt_cntfrq_hz) { + /* + * 0 means "the board didn't set a value, use the default". + * The default value of the generic timer frequency (as seen in + * CNTFRQ_EL0) is 62.5MHz, which corresponds to a period of 16ns. + * This is what you get (a) for a CONFIG_USER_ONLY CPU (b) if the + * board doesn't set it. + */ + cpu->gt_cntfrq_hz =3D GTIMER_DEFAULT_HZ; + } + #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 @@ -1877,18 +1891,7 @@ static void arm_cpu_realizefn(DeviceState *dev, Erro= r **errp) } =20 { - uint64_t scale; - - if (arm_feature(env, ARM_FEATURE_GENERIC_TIMER)) { - if (!cpu->gt_cntfrq_hz) { - error_setg(errp, "Invalid CNTFRQ: %"PRId64"Hz", - cpu->gt_cntfrq_hz); - return; - } - scale =3D gt_cntfrq_period_ns(cpu); - } else { - scale =3D GTIMER_SCALE; - } + uint64_t scale =3D gt_cntfrq_period_ns(cpu); =20 cpu->gt_timer[GTIMER_PHYS] =3D timer_new(QEMU_CLOCK_VIRTUAL, scale, arm_gt_ptimer_cb, cpu); diff --git a/target/arm/helper.c b/target/arm/helper.c index 8bdbb404195..01cf231a861 100644 --- a/target/arm/helper.c +++ b/target/arm/helper.c @@ -2461,6 +2461,13 @@ static const ARMCPRegInfo v6k_cp_reginfo[] =3D { .resetvalue =3D 0 }, }; =20 +static void arm_gt_cntfrq_reset(CPUARMState *env, const ARMCPRegInfo *opaq= ue) +{ + ARMCPU *cpu =3D env_archcpu(env); + + cpu->env.cp15.c14_cntfrq =3D cpu->gt_cntfrq_hz; +} + #ifndef CONFIG_USER_ONLY =20 static CPAccessResult gt_cntfrq_access(CPUARMState *env, const ARMCPRegInf= o *ri, @@ -3215,13 +3222,6 @@ void arm_gt_hvtimer_cb(void *opaque) gt_recalc_timer(cpu, GTIMER_HYPVIRT); } =20 -static void arm_gt_cntfrq_reset(CPUARMState *env, const ARMCPRegInfo *opaq= ue) -{ - ARMCPU *cpu =3D env_archcpu(env); - - cpu->env.cp15.c14_cntfrq =3D cpu->gt_cntfrq_hz; -} - static const ARMCPRegInfo generic_timer_cp_reginfo[] =3D { /* * Note that CNTFRQ is purely reads-as-written for the benefit @@ -3501,7 +3501,7 @@ static const ARMCPRegInfo generic_timer_cp_reginfo[] = =3D { .opc0 =3D 3, .opc1 =3D 3, .crn =3D 14, .crm =3D 0, .opc2 =3D 0, .type =3D ARM_CP_CONST, .access =3D PL0_R /* no PL1_RW in linux-user= */, .fieldoffset =3D offsetof(CPUARMState, cp15.c14_cntfrq), - .resetvalue =3D NANOSECONDS_PER_SECOND / GTIMER_SCALE, + .resetfn =3D arm_gt_cntfrq_reset, }, { .name =3D "CNTVCT_EL0", .state =3D ARM_CP_STATE_AA64, .opc0 =3D 3, .opc1 =3D 3, .crn =3D 14, .crm =3D 0, .opc2 =3D 2, --=20 2.34.1 From nobody Sat May 18 05:05:00 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1713552441; cv=none; d=zohomail.com; s=zohoarc; b=QlGcysb3LwQTNA0hqBp1Z687l6isFCXNiAdys7D/PYj0XgPb1TfjtX97ywTncnLHWclstrtIVQZ3P2NRNniIVym7WNVqxIYMJhwEB2LQBYYsmBqCSC7aGV55qkW3n5OthCaFLJ+Hp+1eaWzhDKLJlPoZzzZCHJKqz48W9oR8o6c= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1713552441; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=nQaBx9r5N0v1ewmC8t+fla4PMGkNo0kCNDVTJv0sKQ0=; b=MpL4DwzxGV2FCKBeVglOfdnNK/RQFt2iy1x69ObMvC5T+moAEarCK6si7nIdhAlQiDIixnK7JIOZnOB+QLOfYuOJq/lv03ZQkfaBtT2PPy927lxGovG6Iloe9SkpjHA8SIVCjN+B7yildbaCWZazn0/ibWKjGh9B4auKJ4LfKL8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1713552441709672.2736903517772; Fri, 19 Apr 2024 11:47:21 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxtFe-00088G-5r; Fri, 19 Apr 2024 14:46:22 -0400 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 1rxtFZ-00086U-Ae for qemu-devel@nongnu.org; Fri, 19 Apr 2024 14:46:17 -0400 Received: from mail-wr1-x42d.google.com ([2a00:1450:4864:20::42d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1rxtFV-00012I-7d for qemu-devel@nongnu.org; Fri, 19 Apr 2024 14:46:16 -0400 Received: by mail-wr1-x42d.google.com with SMTP id ffacd0b85a97d-347c197a464so1623048f8f.2 for ; Fri, 19 Apr 2024 11:46:12 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id cs18-20020a056000089200b003437799a373sm5108718wrb.83.2024.04.19.11.46.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 19 Apr 2024 11:46:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1713552372; x=1714157172; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=nQaBx9r5N0v1ewmC8t+fla4PMGkNo0kCNDVTJv0sKQ0=; b=GqcT31viqtYC+yK9thvU76igP6tEqLmk1edT1DvuRj81+SU/yRwHzMLtumkYBzGB6D Yhiyl/sCHiygN/uBm/hYisuxfTB9SBrZHMBgvPvNPfvFU5s9vZSNNJfHI1wX4YlUhTS8 td1/svA6t8hs7HPjxXJnEBeVdo3fr/+4bn/Maxkw/IVSjyQTs2hedczvskKqkXhw7CXv 6HW/S5bzRw01y2n5ZORi/NG3/wJhmqYxfPREZzEzfYRPoqoB1T3eS9TB5RAEwM31Go8Y E9Lnlne/0CbBWHwFbEFup1vZDY5yi3fy/NtUs/2ezrDfSIAsrn1vuT0p9FlomFLTErPs kdQw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1713552372; x=1714157172; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=nQaBx9r5N0v1ewmC8t+fla4PMGkNo0kCNDVTJv0sKQ0=; b=iGLix8KwrgGdcr9Kd/prkg5TrWkZUnpZEWyBuKYQ7VA2edXBGYepal31USjvjndmyp n98swvO3gjmaE+uplhSuEPpf1qlhVsSc2Yk2/EYaASLyzigtm0xJbxSHjuuVvympCLUg WdZZIDCLsb8AlZzXf5B8jNOqxuSUfh6u4jyfKJBWIcd8Jv1yvcPTW0DQW3WvzIXJNs7x KZ41Ur3quFRWTlhXVfZpMchGdRSN773lPE8nZRlR1VnaE9OJ4TI4pM89gA2EtYfTKnia zJ84O0tVNemUqnbprXffTsUugopviGRSkigRATd7W6riwsNHqMd0EKv+WlsPYtHukQBP LoZQ== X-Forwarded-Encrypted: i=1; AJvYcCXt/bBB6W+syGMCH2Oc6kvPTUxf1QNFMqRV0wrgkt5eBWtQ6lIKR2XbSNg4q0uetEzbnT/PJhnBEUdIdBka0RCtcQGEhYc= X-Gm-Message-State: AOJu0YwE7Eso7XdqjhGsIWZ/wArYMdMf/RMGp2VaUu6DWzW1yD0CVvuY 0q9ZUBYT3XxMlQ1l6nlzchi0G+1oHlAte1hU0tNgQwI9gUtJvd5ERKt9mgXzxBMlUtG29zLevpG Z X-Google-Smtp-Source: AGHT+IGdjmMIK3C4Nlq4n9h61VU3FAlvJ5fqqM5JQuR/7yR+NRzK6fDrM/SaGNcHFWRrqyvyesXNOw== X-Received: by 2002:adf:ce08:0:b0:346:a7:4acb with SMTP id p8-20020adfce08000000b0034600a74acbmr1777083wrn.62.1713552371491; Fri, 19 Apr 2024 11:46:11 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH 3/3] target/arm: Default to 1GHz cntfrq for 'max' and new CPUs Date: Fri, 19 Apr 2024 19:46:08 +0100 Message-Id: <20240419184608.2675213-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240419184608.2675213-1-peter.maydell@linaro.org> References: <20240419184608.2675213-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::42d; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x42d.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1713552442095100004 Content-Type: text/plain; charset="utf-8" In previous versions of the Arm architecture, the frequency of the generic timers as reported in CNTFRQ_EL0 could be any IMPDEF value, and for QEMU we picked 62.5MHz, giving a timer tick period of 16ns. In Armv8.6, the architecture standardized this frequency to 1GHz. Because there is no ID register feature field that indicates whether a CPU is v8.6 or that it ought to have this counter frequency, we implement this by changing our default CNTFRQ value for all CPUs, with exceptions for backwards compatibility: * CPU types which we already implement will retain the old default value. None of these are v8.6 CPUs, so this is architecturally OK. * CPUs used in versioned machine types with a version of 9.0 or earlier will retain the old default value. The upshot is that the only CPU type that changes is 'max'; but any new type we add in future (whether v8.6 or not) will also get the new 1GHz default. It remains the case that the machine model can override the default value via the 'cntfrq' QOM property (regardless of the CPU type). Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Richard Henderson --- target/arm/cpu.h | 11 +++++++++++ target/arm/internals.h | 12 ++++++++++-- hw/core/machine.c | 4 +++- target/arm/cpu.c | 28 ++++++++++++++++++++++------ target/arm/cpu64.c | 2 ++ target/arm/tcg/cpu32.c | 4 ++++ target/arm/tcg/cpu64.c | 18 ++++++++++++++++++ 7 files changed, 70 insertions(+), 9 deletions(-) diff --git a/target/arm/cpu.h b/target/arm/cpu.h index 20d8257c853..4eeeac3fe94 100644 --- a/target/arm/cpu.h +++ b/target/arm/cpu.h @@ -953,6 +953,9 @@ struct ArchCPU { */ bool host_cpu_probe_failed; =20 + /* QOM property to indicate we should use the back-compat CNTFRQ defau= lt */ + bool backcompat_cntfrq; + /* Specify the number of cores in this CPU cluster. Used for the L2CTLR * register. */ @@ -2367,6 +2370,14 @@ enum arm_features { ARM_FEATURE_M_SECURITY, /* M profile Security Extension */ ARM_FEATURE_M_MAIN, /* M profile Main Extension */ ARM_FEATURE_V8_1M, /* M profile extras only in v8.1M and later */ + /* + * ARM_FEATURE_BACKCOMPAT_CNTFRQ makes the CPU default cntfrq be 62.5M= Hz + * if the board doesn't set a value, instead of 1GHz. It is for backwa= rds + * compatibility and used only with CPU definitions that were already + * in QEMU before we changed the default. It should not be set on any + * CPU types added in future. + */ + ARM_FEATURE_BACKCOMPAT_CNTFRQ, /* 62.5MHz timer default */ }; =20 static inline int arm_feature(CPUARMState *env, int feature) diff --git a/target/arm/internals.h b/target/arm/internals.h index 74d4b1b0990..11d9ff0fc08 100644 --- a/target/arm/internals.h +++ b/target/arm/internals.h @@ -61,9 +61,17 @@ static inline bool excp_is_internal(int excp) =20 /* * Default frequency for the generic timer, in Hz. - * This is 62.5MHz, which gives a 16 ns tick period. + * ARMv8.6 and later CPUs architecturally must use a 1GHz timer; before + * that it was an IMPDEF choice, and QEMU initially picked 62.5MHz, + * which gives a 16ns tick period. + * + * We will use the back-compat value: + * - for QEMU CPU types added before we standardized on 1GHz + * - for versioned machine types with a version of 9.0 or earlier + * In any case, the machine model may override via the cntfrq property. */ -#define GTIMER_DEFAULT_HZ 62500000 +#define GTIMER_DEFAULT_HZ 1000000000 +#define GTIMER_BACKCOMPAT_HZ 62500000 =20 /* Bit definitions for the v7M CONTROL register */ FIELD(V7M_CONTROL, NPRIV, 0, 1) diff --git a/hw/core/machine.c b/hw/core/machine.c index a92bec23147..bd40483d880 100644 --- a/hw/core/machine.c +++ b/hw/core/machine.c @@ -33,7 +33,9 @@ #include "hw/virtio/virtio-iommu.h" #include "audio/audio.h" =20 -GlobalProperty hw_compat_9_0[] =3D {}; +GlobalProperty hw_compat_9_0[] =3D { + {"arm-cpu", "backcompat-cntfrq", "true" }, +}; const size_t hw_compat_9_0_len =3D G_N_ELEMENTS(hw_compat_9_0); =20 GlobalProperty hw_compat_8_2[] =3D { diff --git a/target/arm/cpu.c b/target/arm/cpu.c index b248b283423..2c8160d6b74 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1388,6 +1388,11 @@ static void arm_cpu_initfn(Object *obj) static Property arm_cpu_gt_cntfrq_property =3D DEFINE_PROP_UINT64("cntfrq", ARMCPU, gt_cntfrq_hz, 0); =20 +/* True to default to the backwards-compatibility old CNTFRQ rather than 1= Ghz */ +static Property arm_cpu_backcompat_cntfrq_property =3D + DEFINE_PROP_BOOL("backcompat-cntfrq", ARMCPU, + backcompat_cntfrq, false); + static Property arm_cpu_reset_cbar_property =3D DEFINE_PROP_UINT64("reset-cbar", ARMCPU, reset_cbar, 0); =20 @@ -1709,6 +1714,8 @@ void arm_cpu_post_init(Object *obj) qdev_property_add_static(DEVICE(cpu), &arm_cpu_gt_cntfrq_property); } =20 + qdev_property_add_static(DEVICE(obj), &arm_cpu_backcompat_cntfrq_prope= rty); + if (kvm_enabled()) { kvm_arm_add_vcpu_properties(cpu); } @@ -1834,13 +1841,22 @@ static void arm_cpu_realizefn(DeviceState *dev, Err= or **errp) =20 if (!cpu->gt_cntfrq_hz) { /* - * 0 means "the board didn't set a value, use the default". - * The default value of the generic timer frequency (as seen in - * CNTFRQ_EL0) is 62.5MHz, which corresponds to a period of 16ns. - * This is what you get (a) for a CONFIG_USER_ONLY CPU (b) if the - * board doesn't set it. + * 0 means "the board didn't set a value, use the default". (We al= so + * get here for the CONFIG_USER_ONLY case.) + * ARMv8.6 and later CPUs architecturally must use a 1GHz timer; b= efore + * that it was an IMPDEF choice, and QEMU initially picked 62.5MHz, + * which gives a 16ns tick period. + * + * We will use the back-compat value: + * - for QEMU CPU types added before we standardized on 1GHz + * - for versioned machine types with a version of 9.0 or earlier */ - cpu->gt_cntfrq_hz =3D GTIMER_DEFAULT_HZ; + if (arm_feature(env, ARM_FEATURE_BACKCOMPAT_CNTFRQ) || + cpu->backcompat_cntfrq) { + cpu->gt_cntfrq_hz =3D GTIMER_BACKCOMPAT_HZ; + } else { + cpu->gt_cntfrq_hz =3D GTIMER_DEFAULT_HZ; + } } =20 #ifndef CONFIG_USER_ONLY diff --git a/target/arm/cpu64.c b/target/arm/cpu64.c index 985b1efe160..c15d086049f 100644 --- a/target/arm/cpu64.c +++ b/target/arm/cpu64.c @@ -599,6 +599,7 @@ static void aarch64_a57_initfn(Object *obj) 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_BACKCOMPAT_CNTFRQ); set_feature(&cpu->env, ARM_FEATURE_AARCH64); set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); set_feature(&cpu->env, ARM_FEATURE_EL2); @@ -656,6 +657,7 @@ static void aarch64_a53_initfn(Object *obj) 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_BACKCOMPAT_CNTFRQ); set_feature(&cpu->env, ARM_FEATURE_AARCH64); set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); set_feature(&cpu->env, ARM_FEATURE_EL2); diff --git a/target/arm/tcg/cpu32.c b/target/arm/tcg/cpu32.c index b5a60682fa6..bdd82d912a2 100644 --- a/target/arm/tcg/cpu32.c +++ b/target/arm/tcg/cpu32.c @@ -457,6 +457,7 @@ static void cortex_a7_initfn(Object *obj) 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_BACKCOMPAT_CNTFRQ); set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); set_feature(&cpu->env, ARM_FEATURE_EL2); @@ -505,6 +506,7 @@ static void cortex_a15_initfn(Object *obj) 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_BACKCOMPAT_CNTFRQ); set_feature(&cpu->env, ARM_FEATURE_DUMMY_C15_REGS); set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); set_feature(&cpu->env, ARM_FEATURE_EL2); @@ -696,6 +698,7 @@ static void cortex_r52_initfn(Object *obj) set_feature(&cpu->env, ARM_FEATURE_PMSA); set_feature(&cpu->env, ARM_FEATURE_NEON); set_feature(&cpu->env, ARM_FEATURE_GENERIC_TIMER); + set_feature(&cpu->env, ARM_FEATURE_BACKCOMPAT_CNTFRQ); set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); set_feature(&cpu->env, ARM_FEATURE_AUXCR); cpu->midr =3D 0x411fd133; /* r1p3 */ @@ -924,6 +927,7 @@ static void arm_max_initfn(Object *obj) 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_BACKCOMPAT_CNTFRQ); set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); set_feature(&cpu->env, ARM_FEATURE_EL2); set_feature(&cpu->env, ARM_FEATURE_EL3); diff --git a/target/arm/tcg/cpu64.c b/target/arm/tcg/cpu64.c index c3369f40824..b0eb7fbb385 100644 --- a/target/arm/tcg/cpu64.c +++ b/target/arm/tcg/cpu64.c @@ -63,6 +63,7 @@ static void aarch64_a35_initfn(Object *obj) 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_BACKCOMPAT_CNTFRQ); set_feature(&cpu->env, ARM_FEATURE_AARCH64); set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); set_feature(&cpu->env, ARM_FEATURE_EL2); @@ -231,6 +232,7 @@ static void aarch64_a55_initfn(Object *obj) 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_BACKCOMPAT_CNTFRQ); set_feature(&cpu->env, ARM_FEATURE_AARCH64); set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); set_feature(&cpu->env, ARM_FEATURE_EL2); @@ -299,6 +301,7 @@ static void aarch64_a72_initfn(Object *obj) 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_BACKCOMPAT_CNTFRQ); set_feature(&cpu->env, ARM_FEATURE_AARCH64); set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); set_feature(&cpu->env, ARM_FEATURE_EL2); @@ -354,6 +357,7 @@ static void aarch64_a76_initfn(Object *obj) 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_BACKCOMPAT_CNTFRQ); set_feature(&cpu->env, ARM_FEATURE_AARCH64); set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); set_feature(&cpu->env, ARM_FEATURE_EL2); @@ -423,6 +427,7 @@ static void aarch64_a64fx_initfn(Object *obj) 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_BACKCOMPAT_CNTFRQ); set_feature(&cpu->env, ARM_FEATURE_AARCH64); set_feature(&cpu->env, ARM_FEATURE_EL2); set_feature(&cpu->env, ARM_FEATURE_EL3); @@ -592,6 +597,7 @@ static void aarch64_neoverse_n1_initfn(Object *obj) 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_BACKCOMPAT_CNTFRQ); set_feature(&cpu->env, ARM_FEATURE_AARCH64); set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); set_feature(&cpu->env, ARM_FEATURE_EL2); @@ -663,6 +669,7 @@ static void aarch64_neoverse_v1_initfn(Object *obj) 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_BACKCOMPAT_CNTFRQ); set_feature(&cpu->env, ARM_FEATURE_AARCH64); set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); set_feature(&cpu->env, ARM_FEATURE_EL2); @@ -885,6 +892,7 @@ static void aarch64_a710_initfn(Object *obj) 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_BACKCOMPAT_CNTFRQ); set_feature(&cpu->env, ARM_FEATURE_AARCH64); set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); set_feature(&cpu->env, ARM_FEATURE_EL2); @@ -982,6 +990,7 @@ static void aarch64_neoverse_n2_initfn(Object *obj) 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_BACKCOMPAT_CNTFRQ); set_feature(&cpu->env, ARM_FEATURE_AARCH64); set_feature(&cpu->env, ARM_FEATURE_CBAR_RO); set_feature(&cpu->env, ARM_FEATURE_EL2); @@ -1077,6 +1086,15 @@ void aarch64_max_tcg_initfn(Object *obj) uint64_t t; uint32_t u; =20 + /* + * Unset ARM_FEATURE_BACKCOMPAT_CNTFRQ, which we would otherwise defau= lt + * to because we started with aarch64_a57_initfn(). A 'max' CPU might + * be a v8.6-or-later one, in which case the cntfrq must be 1GHz; and + * because it is our "may change" CPU type we are OK with it not being + * backwards-compatible with how it worked in old QEMU. + */ + unset_feature(&cpu->env, ARM_FEATURE_BACKCOMPAT_CNTFRQ); + /* * Reset MIDR so the guest doesn't mistake our 'max' CPU type for a re= al * one and try to apply errata workarounds or use impdef features we --=20 2.34.1