All of lore.kernel.org
 help / color / mirror / Atom feed
From: Lucas Kornicki <lucas.kornicki@nutanix.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>, qemu-devel@nongnu.org
Cc: Mohamed Mediouni <mohamed@unpredictable.fr>,
	qemu-arm@nongnu.org, Peter Maydell <peter.maydell@linaro.org>,
	Alexander Graf <agraf@csgraf.de>,
	Cameron Esfahani <dirty@apple.com>, Mads Ynddal <mads@ynddal.dk>,
	Akihiko Odaki <odaki@rsg.ci.i.u-tokyo.ac.jp>
Subject: Re: [PATCH v5 2/2] target/arm/hvf: Sync CNTV_CTL_EL0 & CNTV_CVAL_EL0
Date: Mon, 23 Feb 2026 14:47:39 +0100	[thread overview]
Message-ID: <84b3b9fc-d448-4da3-b76f-de72c4e775fd@nutanix.com> (raw)
In-Reply-To: <20260118215945.46693-3-philmd@linaro.org>

[-- Attachment #1: Type: text/plain, Size: 3245 bytes --]

Hi. I've found this patch to break EDK2 UEFI on MacOS 15.7
With it applied, the vm is usually stuck on display not initialized, but 
sometimes it will init and hang on the tianocore logo.
I've narrowed it down to

b = hvf_sysreg_write_cp(cpu, "VTimer", SYSREG_CNTV_CVAL_EL0, val);

in hvf_arch_get_registers.

On a related note, I've noticed that when using accel=hvf on aarch64, 
the cpu usage is maxing out all assigned cores even if the guest is 
idle. It looks like it's constantly getting woken up from WFI. Could 
this patch be part of the solution?

On 1/18/26 22:59, Philippe Mathieu-Daudé wrote:
> Keep CNTV_CTL_EL0 and CNTV_CVAL_EL0 synchronized with the
> host hardware accelerator.
>
> Signed-off-by: Philippe Mathieu-Daudé<philmd@linaro.org>
> ---
>   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;
>   }
>   

[-- Attachment #2: Type: text/html, Size: 3860 bytes --]

  parent reply	other threads:[~2026-02-23 14:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-18 21:59 [PATCH v5 0/2] accel/hvf: Sync CNTV_CTL_EL0 & CNTV_CVAL_EL0 Philippe Mathieu-Daudé
2026-01-18 21:59 ` [PATCH v5 1/2] target/arm/hvf: Move hvf_sysreg_[read, write]_cp() functions around Philippe Mathieu-Daudé
2026-01-18 21:59 ` [PATCH v5 2/2] target/arm/hvf: Sync CNTV_CTL_EL0 & CNTV_CVAL_EL0 Philippe Mathieu-Daudé
2026-02-12 15:05   ` Zenghui Yu
2026-02-17 21:36     ` Philippe Mathieu-Daudé
2026-02-15 10:15   ` Mohamed Mediouni
2026-02-17 21:37     ` Philippe Mathieu-Daudé
2026-02-23 13:47   ` Lucas Kornicki [this message]
2026-03-02 12:18     ` Zenghui Yu
2026-01-18 23:26 ` [PATCH v5 0/2] accel/hvf: " Richard Henderson
2026-01-19  3:12 ` Akihiko Odaki
2026-01-26 15:57 ` Peter Maydell

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=84b3b9fc-d448-4da3-b76f-de72c4e775fd@nutanix.com \
    --to=lucas.kornicki@nutanix.com \
    --cc=agraf@csgraf.de \
    --cc=dirty@apple.com \
    --cc=mads@ynddal.dk \
    --cc=mohamed@unpredictable.fr \
    --cc=odaki@rsg.ci.i.u-tokyo.ac.jp \
    --cc=peter.maydell@linaro.org \
    --cc=philmd@linaro.org \
    --cc=qemu-arm@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.