From nobody Sun Nov 16 02:46:45 2025 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=1762184903; cv=none; d=zohomail.com; s=zohoarc; b=VjQpdrrDooQX2YN7NEgvv/Q+ydWifLtrHaa6EXRX8NZiQ2WrLpH1KXypBe8x5+GyS4ZT6WZz9lQKtECxiFDeJnzJJREOI4Wk1qDxKYzeyB6kQQGQSY+86gji75ieRQ5wIeRMTOFK8zMzVCCqL8nH2uI7VLJloL3Kan3HKYuYx+Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1762184903; h=Content-Type: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=n9WMPu5LSRciOJbiNa7PDj4nCkCQX4hBl0JqndlpJPI=; b=muwZ2EhmneXTesIJPBajKS8Llump7rhUTVJWKzdVwKjSYLXXQiDIThOODqtvNZac3rKo5JgfO7BQyxDxc2r6x4qISxZ2hIcm8tQ+rvCtIhHwnwjiw6C3cUNBYk2Me3cVIQHmuP5m73abgIjwN00VDZdgB7p/Hi6+EajYSW2m/1I= 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 1762184902996453.5369790873185; Mon, 3 Nov 2025 07:48:22 -0800 (PST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vFwm7-0005AN-Dl; Mon, 03 Nov 2025 10:47: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 1vFwm4-00059g-U4 for qemu-devel@nongnu.org; Mon, 03 Nov 2025 10:47:17 -0500 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 1vFwlx-0002iK-49 for qemu-devel@nongnu.org; Mon, 03 Nov 2025 10:47:16 -0500 Received: by mail-wr1-x434.google.com with SMTP id ffacd0b85a97d-3ee130237a8so2779318f8f.0 for ; Mon, 03 Nov 2025 07:47:06 -0800 (PST) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-429ce6b0c16sm10504156f8f.38.2025.11.03.07.47.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Nov 2025 07:47:03 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1762184824; x=1762789624; 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=n9WMPu5LSRciOJbiNa7PDj4nCkCQX4hBl0JqndlpJPI=; b=FxYKw9Zj9RMksQydTQTcLOWlgw6+a0WecliQnvxskWP4e9YKUMWkq45t4na5AAPtfM La4ADXOh8biWmw4sejtsycq8j6YJn+AEiNtcOIRYIIGr6isU3CPw2LTJicUzTa4hCUIm JQ8yc9CHSHexGRB45/jXi1iCht8Is5BiXtJQjxmBq09gRY9TeDDFq0AVTAvOuI/zrTXM MqX1FVclMmm3dFqiUjgCZm5dl4RRZ4BhtvtFe3a12yH3NHkZAShABu5nAnMZ8ZRUBbUb WkfQqAhkpeEeyGoi+p4vNFmf6nxPDZ+ESbhr4GsVyGGB5WMenulCRt+n/M84UFa1VABp jZ/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1762184824; x=1762789624; 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=n9WMPu5LSRciOJbiNa7PDj4nCkCQX4hBl0JqndlpJPI=; b=TbWUONQdD7ZtM/FR5aTMgcmWl7hkAwWa4BrPqTthfkfHOjAkcnM1h/k3zV/bcJGwKK fVTEmh4ycUwIx0OgpqpmGlG5sF7FgyjgSlnwro5OGt47uVPrBEAAlk8McPV7qngrWmMs e3/v1bdQOUxB0cRdS/R/HcDMjfCqKef8OCUNbHjEqr3/h1CuJyct4UU6yMPuRzb30BwR 9CtOZtzocNP+JKl3IKETU3XrFwz/fjWfFDeRoblbLRl2Q+HohMZdPDOrgQIPloowRX4N z4GMfC7Q1gj15/XSY/9DZq8xcet0WqRs4Cy3nszDPfE2AJPc4kzb7jQjNKbg8Ebx3Rlt doVg== X-Gm-Message-State: AOJu0Yxswagcr/9+QX+fb477K4YHlHcGfjpFBez7p9+tP32R1VtnbVRO hxolLeM5uJ1MarWJIwTuD1Eeor+UOi7fC8D0KxAZuDdBiBe57cGwa3SbSJOeAjVjlUoltoDCGMs pIkxB X-Gm-Gg: ASbGncvmGxUPSaeOTsPAshIGP9CzVBS5YJ2dXp8uhnlgFffHux4AH+s5V0jJbDAcYwy zOizwrsMzlEQKuFsE0tHuIgYQQYOj7a6YQHOJPJHDqykRS0cF7I+n1GqKMlg0U7MVxCT6UGEJTw p3fbKt+0Lq0xALxwESivYkgP+C93WeFmLapyUg96bD6yHQEW4TMN2gt8XLByh3KsHJkUfEzXMgV JCEg3X18R8AENwLvpdjk4VnZJ8GCYRQ6XHIEbvCDeg9jzmcnHFHXP/bhLVlo3mQuOYtGgQK+rgT xQXPfGET5eFSEQekMfwnoW0CTKjahIVLMX9Us0aOmRGyuoA+MNjoNQqGElcYaSDuq1i8LXUDsS2 0a9/2ruMxNF1S/KMAg7ZuomldVR30+Sa47JWelzvg41NiJTtFdqE77QXce4DnfIXluTgYnDONhQ 06LQj6A/75c3QUeT1w X-Google-Smtp-Source: AGHT+IEP1oDBh0dhJDzbuBNPkLPbUpTPMNaXukSdhTGBsv8U5aoQ1GW1irfF/haVksNQnVWyzhPnsw== X-Received: by 2002:a05:6000:2306:b0:3ea:80ec:8552 with SMTP id ffacd0b85a97d-429bd6e3d86mr10926614f8f.57.1762184824307; Mon, 03 Nov 2025 07:47:04 -0800 (PST) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 2/3] hw/arm/imx8mp-evk: Fix guest time in KVM mode Date: Mon, 3 Nov 2025 15:46:59 +0000 Message-ID: <20251103154700.4126379-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251103154700.4126379-1-peter.maydell@linaro.org> References: <20251103154700.4126379-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=2a00:1450:4864:20::434; envelope-from=peter.maydell@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, T_SPF_TEMPERROR=0.01 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: 1762184909063158500 From: Bernhard Beschow The imx8mp DTB hardcodes the clock frequency of the system counter to 8MHz. In KVM mode, the host CPU is used whose system counter runs at a different frequency, resulting in the guest clock running slower or faster. Fix this by not hardcoding the clock frequency which makes the Linux driver read the real clock frequency from the register. Reviewed-by: Philippe Mathieu-Daud=C3=A9 Signed-off-by: Bernhard Beschow Message-id: 20251101120130.236721-3-shentey@gmail.com Signed-off-by: Peter Maydell --- hw/arm/imx8mp-evk.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/hw/arm/imx8mp-evk.c b/hw/arm/imx8mp-evk.c index 3ddcf1af5ac..44e06019670 100644 --- a/hw/arm/imx8mp-evk.c +++ b/hw/arm/imx8mp-evk.c @@ -44,6 +44,15 @@ static void imx8mp_evk_modify_dtb(const struct arm_boot_= info *info, void *fdt) fdt_nop_property(fdt, offset, "cpu-idle-states"); offset =3D fdt_node_offset_by_compatible(fdt, offset, "arm,cortex-= a53"); } + + if (kvm_enabled()) { + /* Use system counter frequency from host CPU to fix time in guest= */ + offset =3D fdt_node_offset_by_compatible(fdt, -1, "arm,armv8-timer= "); + while (offset >=3D 0) { + fdt_nop_property(fdt, offset, "clock-frequency"); + offset =3D fdt_node_offset_by_compatible(fdt, offset, "arm,arm= v8-timer"); + } + } } =20 static void imx8mp_evk_init(MachineState *machine) --=20 2.43.0