Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id A7B0AC83F17 for ; Wed, 23 Jul 2025 13:58:26 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ueZxn-0004oi-UR; Wed, 23 Jul 2025 09:56:56 -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 1ueZtL-0002u8-7z for qemu-arm@nongnu.org; Wed, 23 Jul 2025 09:52:19 -0400 Received: from mail-wr1-x434.google.com ([2a00:1450:4864:20::434]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ueZtI-0002qV-CN for qemu-arm@nongnu.org; Wed, 23 Jul 2025 09:52:18 -0400 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3a536ecbf6fso3928676f8f.2 for ; Wed, 23 Jul 2025 06:52:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1753278734; x=1753883534; darn=nongnu.org; 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=WiARY+eRyGpj1UCxkCuj/Q44h4QzLd4Og99m8x5oSqA=; b=uGPGDRiJgJW1Ri8NI0SiF3R9RoFiekE5OxoYU/wvTCsLNPu2TPSq8bXYNdLGoX3sM/ WaX50YtTEP8NWdm54cSZ/jWPTJzJM5KjFAERwgMvH7S2+F25cgYofQgprOPYJH6OgxLl OevAsgmG85WiSvk80FRlzDgL3l9+hMcVYYFiG1RzQ2htGS2G0Lzld3p9OqBitaVgfE0w nXKQReRAdoc0mtypcABjdk7HkRrV7VvWy06iHZJMFtTUaWHnHUS7SE0RA055W8j7B+yK 3gxAO/9/erq4cbKEWxcJ+2sVPEmxE9WQO+pmX+TZHkpQ/HVjBIDQAwK9LjlM35ZFWNAJ N//g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1753278734; x=1753883534; 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=WiARY+eRyGpj1UCxkCuj/Q44h4QzLd4Og99m8x5oSqA=; b=jmoPFEcOlm562dv7Lw8kd/AUSN/WH0NQblbvDRCW4zqO9cOgZpZGhfQHbhvRyu7oXW dFwd05GTmiAJB59Pv8m/kAGPFCQgmAP2+BY2bOXtEiZC8XFl2htRJOoV7bLqu4WEopPQ WJRmxdaVARNq6CW5tpvtgRhuf7iLGOdKu76Ds63SegPAJwtlhFi9EU91e8JRcWr0lzVI lROskF2W5z2JHKaZuV/J8/SUSz7WrXg1N7+Mf23+JtEBQABDjYB0SGMpX1pBIxEqJVs/ gEVLf7KN55UJvwCQs44vtOvgMEyUsoeUpRo4POJXtGSzcSZPy/6+bYk35e9j38pFlgwR QpIg== X-Gm-Message-State: AOJu0YyDoV/rgxONOMl4+ZudLXzDjqP8eKn7Z4yOnxDWERds+B6+Rmc8 OdTn6AHnoagtYPpTl5lMnbut2fQN95kyLoPJdV1g5VAleCLelAl2zCbgQ5rHM4bcy88= X-Gm-Gg: ASbGncsHsCj59zmH7VA98WU3daKEUGSuVpgB9JSkoxsBsaA6dl94NbsWX1H+JqAODIF +zV9/RDAiwm/61EoHFHVzy6FA0SQIlNJxG0S0qYwhqf3NYGOtB4z48FmvWpbSkRM1ID/FiDxkZZ SI53hVQ9Q0etx9voJW5QMfX3DR5dzqqnIisoDXZLD0ekT9DwtsXqLmtwotMpjV5sCww2pSxR9wr 8A/08RlJPgbvGGY4mXBnuR4SjRUhnv/nWCnDabI6qS3HA70w8K9uoh9sCcrd597otkCVoTF6Q0H N1R9N+mOwqBD9bH53IKCWUGpVF+R/0HcxHddHlMZN87b8p39qzf57+D5Ynjh0kPUrFPLYWfsvKT MpDP6jFKS1RfqafRIVAcXDxGPnDgydg35T7WwxipT1LTKeQ0ePaGoiwSJ5IZ1UVdydBGOUwvp X-Google-Smtp-Source: AGHT+IGOGeaNpp/3rjwqSfe7zdH2Up3/bgh9seutQ6iWn2IBT0XPLD6MPpsDf4oznKcs0iaK81+G4A== X-Received: by 2002:a05:6000:2c0c:b0:3b6:333:256f with SMTP id ffacd0b85a97d-3b768f27e15mr2455163f8f.58.1753278733653; Wed, 23 Jul 2025 06:52:13 -0700 (PDT) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-3b61ca2bf4bsm16292187f8f.31.2025.07.23.06.52.12 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Wed, 23 Jul 2025 06:52:13 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: qemu-arm@nongnu.org, Mohamed Mediouni , Phil Dennis-Jordan , Roman Bolshakov , Peter Maydell , Paolo Bonzini , Alexander Graf , Mads Ynddal , Cameron Esfahani , Richard Henderson , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH-for-10.1 v4 3/4] target/arm: Create GTimers *after* features finalized / accel realized Date: Wed, 23 Jul 2025 15:51:55 +0200 Message-ID: <20250723135156.85426-4-philmd@linaro.org> X-Mailer: git-send-email 2.49.0 In-Reply-To: <20250723135156.85426-1-philmd@linaro.org> References: <20250723135156.85426-1-philmd@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=philmd@linaro.org; helo=mail-wr1-x434.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-arm@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-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org Sender: qemu-arm-bounces+qemu-arm=archiver.kernel.org@nongnu.org Call generic (including accelerator) cpu_realize() handlers *before* setting @gt_cntfrq_hz default Signed-off-by: Philippe Mathieu-Daudé Reviewed-by: Richard Henderson --- target/arm/cpu.c | 65 ++++++++++++++++++++++++------------------------ 1 file changed, 33 insertions(+), 32 deletions(-) diff --git a/target/arm/cpu.c b/target/arm/cpu.c index e2b2337399c..70755fc7e87 100644 --- a/target/arm/cpu.c +++ b/target/arm/cpu.c @@ -1992,26 +1992,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) return; } - if (!cpu->gt_cntfrq_hz) { - /* - * 0 means "the board didn't set a value, use the default". (We also - * get here for the CONFIG_USER_ONLY case.) - * 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 - */ - if (arm_feature(env, ARM_FEATURE_BACKCOMPAT_CNTFRQ) || - cpu->backcompat_cntfrq) { - cpu->gt_cntfrq_hz = GTIMER_BACKCOMPAT_HZ; - } else { - cpu->gt_cntfrq_hz = 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 @@ -2058,7 +2038,40 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) return; } } +#endif + cpu_exec_realizefn(cs, &local_err); + if (local_err != NULL) { + error_propagate(errp, local_err); + return; + } + + arm_cpu_finalize_features(cpu, &local_err); + if (local_err != NULL) { + error_propagate(errp, local_err); + return; + } + + if (!cpu->gt_cntfrq_hz) { + /* + * 0 means "the board didn't set a value, use the default". (We also + * get here for the CONFIG_USER_ONLY case.) + * 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 + */ + if (arm_feature(env, ARM_FEATURE_BACKCOMPAT_CNTFRQ) || + cpu->backcompat_cntfrq) { + cpu->gt_cntfrq_hz = GTIMER_BACKCOMPAT_HZ; + } else { + cpu->gt_cntfrq_hz = GTIMER_DEFAULT_HZ; + } + } +#ifndef CONFIG_USER_ONLY { uint64_t scale = gt_cntfrq_period_ns(cpu); @@ -2079,18 +2092,6 @@ static void arm_cpu_realizefn(DeviceState *dev, Error **errp) } #endif - cpu_exec_realizefn(cs, &local_err); - if (local_err != NULL) { - error_propagate(errp, local_err); - return; - } - - arm_cpu_finalize_features(cpu, &local_err); - if (local_err != NULL) { - error_propagate(errp, local_err); - return; - } - #ifdef CONFIG_USER_ONLY /* * User mode relies on IC IVAU instructions to catch modification of -- 2.49.0