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 0561CC98315 for ; Sun, 18 Jan 2026 22:00:21 +0000 (UTC) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1vhaoa-0003rU-DO; Sun, 18 Jan 2026 17:00: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 1vhaoZ-0003q6-Be for qemu-arm@nongnu.org; Sun, 18 Jan 2026 17:00:07 -0500 Received: from mail-wm1-x32b.google.com ([2a00:1450:4864:20::32b]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1vhaoX-0008WJ-KX for qemu-arm@nongnu.org; Sun, 18 Jan 2026 17:00:07 -0500 Received: by mail-wm1-x32b.google.com with SMTP id 5b1f17b1804b1-4801bbbdb4aso17159035e9.1 for ; Sun, 18 Jan 2026 14:00:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1768773604; x=1769378404; 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=pijc4SGaIxjhH3hv/CpBfkcN+nrHKNQfSy0KVIp/tpg=; b=jpK4WCfFHllo+/ae0q0gm6BOFWxRKQ8AykPc7gejav1BKqlWTMbvhI6ZMQFRtIY4V0 ZWp1L7e0kz4//uMjbMIeFdw15rl0ybl2xJsbuY723z0pnMKLzsXsBV5O56jbgSj+NUhl 1fRAu7BlJgN82BAx6A8DJWYyBKmxRzH1df8X9htL4x/RBgn30vWVrZPqY5WmdVDNuNXJ l8BD1SH4XayOtCE9KHbv3ljKV15LZBnX5u1iyLkDZRrFSU8/DRxGPeElUnnWUy9qX8Zu 3Gy+m2Mm2hE9B6MNxmcC+r35Nk5mY9EZ4ttq9sp3WzEcfFTvRGBE2XqGtnjek35/CBIR 8Osw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1768773604; x=1769378404; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from :to:cc:subject:date:message-id:reply-to; bh=pijc4SGaIxjhH3hv/CpBfkcN+nrHKNQfSy0KVIp/tpg=; b=YkRNlslDuKoMit1XKVrinAzt9ZTRqbOEt4FoZxoprnspOsd6CiPVynf3vxfp84iHiI bLmB4ScRQOViEiGd78/bM3DtcpBRojiv7EvBHXDdLUOJh7mtCks5JgK00wh1oeXaL+H1 BajSERUQgo3QvQhf5XQ0bvlCEI55kMEgJq74JxZz91HyoYsouim7YpNsZD7WDymTf1qe gXmVfL435iw2H+8mjg2QUpP6aJn9kAP+eanFcxesr2uB6D1+CpzWUyrA3LyPEKbiaSq7 mmXORIWDkCr0Rwt9397ZyLMChDXKT+8UDsvO2GdWSXPn2ycsL7ZeiiAz4GmkNWGOjgTa 1cNg== X-Forwarded-Encrypted: i=1; AJvYcCWsuRv4GMLHwjWZDKmWFnrOAEugXZWiT1xgDFCxqifWJLGm1pqUlF1ENWk0JNlbv0W9xKAJcMWNHw==@nongnu.org X-Gm-Message-State: AOJu0Yym9ESwC0YOrRB/IAE2+89Po4Yl68MWQRJSczlA4RbX+zBU0C6c wdYuwhAo+1mrG8mCiOJGJsDiT+58k/xIHVFZIET2ZOl68IX3PQB+Jn0rYZ2GOnOm9x8= X-Gm-Gg: AY/fxX6ux+5dktA1iebgXZ6dWuPkTQt7QSKYKn3GDYRW1xE7HicjkujhmqDW94WmbuJ ig8w+8v0mhei1Bql2ajNcVTI+VoBDbE7TkGZErMiRynhTTOK8eJ98timM4BzheO5I6S6NxDNvGA 0A6mHmgGFg1fDaQFV3+wU1UAo8P8wT4LT4VJAMaaotxFrX6hWpsqo+UGjtLGRdjFNovLzy9hGjW c2AYMpZOU9QOywwXt2A2FLh6+LpJH3WPIUo2oQOHf4jhO2I6d0o/vBhcywvTcCb9huFY2yqrWV0 fP0/DrOLUgFY7u/oHs9noXJi6weLdDVDI7rtncR02cwaqdT4slTnEnAAlqOItdPZeANRK7iiN9h zQEuAfJ1X3wgN0l4rs1CPGjNwHJLP43BOjIxcmHZbPYL0Mrcgt3I/LGlFP4XVmICLklUuXR8mcY 5AKfPnzosvb0wvy+GUb+2SS/x0WQJYDG2Qmq8t3CQcxArLb7DwhFpKn3cv5DjH3KVtxsDbXww= X-Received: by 2002:a05:600c:3e8e:b0:47b:deb9:163d with SMTP id 5b1f17b1804b1-4801e53c118mr104787115e9.7.1768773604014; Sun, 18 Jan 2026 14:00:04 -0800 (PST) Received: from localhost.localdomain (88-187-86-199.subs.proxad.net. [88.187.86.199]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-47f4b26764fsm214997135e9.12.2026.01.18.14.00.02 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Sun, 18 Jan 2026 14:00:02 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Mohamed Mediouni , qemu-arm@nongnu.org, Peter Maydell , Alexander Graf , Cameron Esfahani , Mads Ynddal , Akihiko Odaki , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v5 2/2] target/arm/hvf: Sync CNTV_CTL_EL0 & CNTV_CVAL_EL0 Date: Sun, 18 Jan 2026 22:59:45 +0100 Message-ID: <20260118215945.46693-3-philmd@linaro.org> X-Mailer: git-send-email 2.52.0 In-Reply-To: <20260118215945.46693-1-philmd@linaro.org> References: <20260118215945.46693-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::32b; envelope-from=philmd@linaro.org; helo=mail-wm1-x32b.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 Keep CNTV_CTL_EL0 and CNTV_CVAL_EL0 synchronized with the host hardware accelerator. Signed-off-by: Philippe Mathieu-Daudé --- target/arm/hvf/hvf.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/target/arm/hvf/hvf.c b/target/arm/hvf/hvf.c index fcb7fa3b30c..9ce720793d8 100644 --- a/target/arm/hvf/hvf.c +++ b/target/arm/hvf/hvf.c @@ -200,6 +200,9 @@ void hvf_arm_init_debug(void) #define SYSREG_PMCEID0_EL0 SYSREG(3, 3, 9, 12, 6) #define SYSREG_PMCEID1_EL0 SYSREG(3, 3, 9, 12, 7) #define SYSREG_PMCCNTR_EL0 SYSREG(3, 3, 9, 13, 0) + +#define SYSREG_CNTV_CTL_EL0 SYSREG(3, 3, 14, 3, 1) +#define SYSREG_CNTV_CVAL_EL0 SYSREG(3, 3, 14, 3, 2) #define SYSREG_PMCCFILTR_EL0 SYSREG(3, 3, 14, 15, 7) #define SYSREG_ICC_AP0R0_EL1 SYSREG(3, 0, 12, 8, 4) @@ -502,6 +505,7 @@ int hvf_arch_get_registers(CPUState *cpu) uint64_t val; hv_simd_fp_uchar16_t fpval; int i, n; + bool b; for (i = 0; i < ARRAY_SIZE(hvf_reg_match); i++) { ret = hv_vcpu_get_reg(cpu->accel->fd, hvf_reg_match[i].reg, &val); @@ -631,6 +635,16 @@ int hvf_arch_get_registers(CPUState *cpu) aarch64_restore_sp(env, arm_current_el(env)); + ret = hv_vcpu_get_sys_reg(cpu->accel->fd, HV_SYS_REG_CNTV_CVAL_EL0, &val); + assert_hvf_ok(ret); + b = hvf_sysreg_write_cp(cpu, "VTimer", SYSREG_CNTV_CVAL_EL0, val); + assert(b); + + ret = hv_vcpu_get_sys_reg(cpu->accel->fd, HV_SYS_REG_CNTV_CTL_EL0, &val); + assert_hvf_ok(ret); + b = hvf_sysreg_write_cp(cpu, "VTimer", SYSREG_CNTV_CTL_EL0, val); + assert(b); + return 0; } @@ -642,6 +656,7 @@ int hvf_arch_put_registers(CPUState *cpu) uint64_t val; hv_simd_fp_uchar16_t fpval; int i, n; + bool b; for (i = 0; i < ARRAY_SIZE(hvf_reg_match); i++) { val = *(uint64_t *)((void *)env + hvf_reg_match[i].offset); @@ -756,6 +771,16 @@ int hvf_arch_put_registers(CPUState *cpu) ret = hv_vcpu_set_vtimer_offset(cpu->accel->fd, hvf_state->vtimer_offset); assert_hvf_ok(ret); + b = hvf_sysreg_read_cp(cpu, "VTimer", SYSREG_CNTV_CVAL_EL0, &val); + assert(b); + ret = hv_vcpu_set_sys_reg(cpu->accel->fd, HV_SYS_REG_CNTV_CVAL_EL0, val); + assert_hvf_ok(ret); + + b = hvf_sysreg_read_cp(cpu, "VTimer", SYSREG_CNTV_CTL_EL0, &val); + assert(b); + ret = hv_vcpu_set_sys_reg(cpu->accel->fd, HV_SYS_REG_CNTV_CTL_EL0, val); + assert_hvf_ok(ret); + return 0; } -- 2.52.0