From patchwork Tue Apr 30 16:48:32 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 793352 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:54f:b0:34d:5089:5a9e with SMTP id b15csp367269wrf; Tue, 30 Apr 2024 09:52:52 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCXyJc2ZUsnZFfan7zMo4nSFpQuoLLIqD4TMASDXnxhxANAdPuHpMfHv7AMyG4spli/VnUwXgXccANQueEakKLYv X-Google-Smtp-Source: AGHT+IF9tnZlHkUfZ90j9XBRPVNt2h6B6kE0XEEDI4csXwBDEIB6lUVV2jH98Jcl3LcAJU0khG6n X-Received: by 2002:a05:690c:884:b0:610:e9b2:f84a with SMTP id cd4-20020a05690c088400b00610e9b2f84amr145110ywb.26.1714495972226; Tue, 30 Apr 2024 09:52:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714495972; cv=none; d=google.com; s=arc-20160816; b=Y1GT/voyHpfqLa7JBXD9HvHcAsc4w/HMCaG0ty+1NXqJsEjRd5uJOqK6QZN/MBn0l7 Sg068FSxWDaQuyesoIAhuS9bE8pwT9uymiTmbT4D7IzsJB0+hMrG/8JcLIvBzzfOa+db I/drGXc0F7gC371I6AHzk8da2cz5JqegML/aAoEsJCgvA05LHtlBzKpvgFlC3/cd9EvK sAwyVtN1YHD8oMU7iMpcAjcnD35qWP3N38HDz2XGugKgu1GbcmzZorCyuCH14iAr6/pO cF6CTHVrU3vEk1Zt+2pHDyHwLOjaHAkj0+s5fTyCs57m9HQG8pE9/EKtJiFE/1WTfKys P/hQ== 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:to:from :dkim-signature; bh=1X3KDYbraVKCKoUyzCUTAqrQ2WBUY6nJhep+vymKNJo=; fh=PnYt+qEB9tAfMKoqBm2xjKOFpYyFFGPudh5cVIoieJM=; b=c3/rxRWhm07ql8JfR8dQhaK0D6EMGcl634xMjy7/bbD04p+/mxHYkLxhvTc7Nl7qSq fHicqbgGHu7K5xm6phzYg+gsmGJSkAd4PNUPPNhrjJdUuVlhxuOKWd22S2OiPBDVw0rc gbibuaK+tsi4o8Fec8LSwA4iLjeikmbMv4Y2ZXPRhXm89Wzpa10CUNIXEyxGVbcDWDeu XMnXvl8R7ZqzswjVMneILbPCS0xDtN3BS22FIkaHrd0tf1RaUFccABqh6qOdJhFhoNqd lV0N1zEsn8VsQ7xjeyipffCCe+oFcHrpxOAkZaiZVpptSFmi1XyNTiQYQv1vs3Xw1xIF ZJlg==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=v8hcm6YM; 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 x2-20020a05622a000200b0043ac9de1addsi6465218qtw.74.2024.04.30.09.52.52 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Tue, 30 Apr 2024 09:52:52 -0700 (PDT) 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=v8hcm6YM; 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 1s1qfO-0002hf-Lz; Tue, 30 Apr 2024 12:49:18 -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 1s1qf3-0002Od-9f for qemu-devel@nongnu.org; Tue, 30 Apr 2024 12:48:58 -0400 Received: from mail-wm1-x331.google.com ([2a00:1450:4864:20::331]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s1qex-0005ch-5O for qemu-devel@nongnu.org; Tue, 30 Apr 2024 12:48:57 -0400 Received: by mail-wm1-x331.google.com with SMTP id 5b1f17b1804b1-41c011bb920so17360185e9.1 for ; Tue, 30 Apr 2024 09:48:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714495729; x=1715100529; 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=1X3KDYbraVKCKoUyzCUTAqrQ2WBUY6nJhep+vymKNJo=; b=v8hcm6YMeTWKkpCVzRagK5XBUxb8gjKv7Y5EFHzsAkikIrJ7bx59i51I2Ia8aQVD4v VXjhXBeGPiPQgn7t05DF4dM7n6pYybD2kFomA38xnXbh4/qxypUArdujCTzXIGXRJT7G kO5Bw2Q2GYnbkNSiURJSJVf6RDpMiDBS98iVaaTYFOAaphua9KMg8NgJ6G8y42EBiibf ZdLCnR6wUaLmy7N/HnCiPbBhI4nuXMu04aAQKHl2XEm9t8FkPOihr4852JgG24djyvhC WkU09/F0o75OkVtNJ9F9A5PzZCJzTr3cCyVIYBVXLRWO004qdB9pDzX8eeFSDTWuc+Il ahXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714495729; x=1715100529; 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=1X3KDYbraVKCKoUyzCUTAqrQ2WBUY6nJhep+vymKNJo=; b=tP6TTmUs8XxSHMnpjq5OHVeI0iKWsjHzM1/FXHQHoyA6D6D/RWS+tzQJ4xNkPDZqhL Q309MNc4iEHdb4JQzk7r7fjLfHUudjFq6iFgFvkChpV+xDQW7+b3O6eoUP3AFZXuj4VL 7whnJXd4+ypCwg6I9kquX3/Obavs2nifpMp5FMBX3KqtNkX7TgvRjJj8OiPm1+yV4QES nGSM1IZCfVZgWaVq5XQ1t6l45aRmjp+wSJ7QfyTgW/ujMCMyEP3uL6DMyQs1dK0xjjXQ UavQ8b8Kez6nZYVccdf21mHwbuDaEog3I6hyVhJEahB0L0waCkyn7ApIm8tDyTJS13kG PUZw== X-Gm-Message-State: AOJu0Yy1JkKjgvzVkAEpSFchPiJq6SH5JT7NBZf19DjL/zfTeuDBtpxt Tth6DPJT+LbLsDDS2uGKCnC17z5nQzQMVUwJw9BYZ1X4y9WFmtoMj3RC3FVQC+ffI+ReG/PCCP1 I X-Received: by 2002:a05:600c:35ca:b0:41b:9427:562e with SMTP id r10-20020a05600c35ca00b0041b9427562emr385077wmq.12.1714495729646; Tue, 30 Apr 2024 09:48:49 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id b6-20020a05600c4e0600b0041be3383a2fsm12920384wmq.19.2024.04.30.09.48.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 30 Apr 2024 09:48:49 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 11/21] hw/arm/sbsa-ref: Force CPU generic timer to 62.5MHz Date: Tue, 30 Apr 2024 17:48:32 +0100 Message-Id: <20240430164842.4074734-12-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240430164842.4074734-1-peter.maydell@linaro.org> References: <20240430164842.4074734-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::331; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x331.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 Currently QEMU CPUs always run with a generic timer counter frequency of 62.5MHz, but ARMv8.6 CPUs will run at 1GHz. For older versions of the TF-A firmware that sbsa-ref runs, the frequency of the generic timer is hardcoded into the firmware, and so if the CPU actually has a different frequency then timers in the guest will be set incorrectly. The default frequency used by the 'max' CPU is about to change, so make the sbsa-ref board force the CPU frequency to the value which the firmware expects. Newer versions of TF-A will read the frequency from the CPU's CNTFRQ_EL0 register: https://github.com/ARM-software/arm-trusted-firmware/commit/4c77fac98dac0bebc63798aae9101ac865b87148 so in the longer term we could make this board use the 1GHz frequency. We will need to make sure we update the binaries used by our avocado test Aarch64SbsarefMachine.test_sbsaref_alpine_linux_max_pauth_impdef before we can do that. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Marcin Juszkiewicz Message-id: 20240426122913.3427983-3-peter.maydell@linaro.org --- hw/arm/sbsa-ref.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c index f5709d6c141..36f6f717b4b 100644 --- a/hw/arm/sbsa-ref.c +++ b/hw/arm/sbsa-ref.c @@ -60,6 +60,19 @@ #define NUM_SMMU_IRQS 4 #define NUM_SATA_PORTS 6 +/* + * Generic timer frequency in Hz (which drives both the CPU generic timers + * and the SBSA watchdog-timer). Older versions of the TF-A firmware + * typically used with sbsa-ref (including the binaries in our Avocado test + * Aarch64SbsarefMachine.test_sbsaref_alpine_linux_max_pauth_impdef + * assume it is this value. + * + * TODO: this value is not architecturally correct for an Armv8.6 or + * better CPU, so we should move to 1GHz once the TF-A fix above has + * made it into a release and into our Avocado test. + */ +#define SBSA_GTIMER_HZ 62500000 + enum { SBSA_FLASH, SBSA_MEM, @@ -767,6 +780,8 @@ static void sbsa_ref_init(MachineState *machine) &error_abort); } + object_property_set_int(cpuobj, "cntfrq", SBSA_GTIMER_HZ, &error_abort); + object_property_set_link(cpuobj, "memory", OBJECT(sysmem), &error_abort);