From: Marc Zyngier <maz@kernel.org>
To: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
Cc: linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev,
linux-arm-kernel@lists.infradead.org, Christoffer.Dall@arm.com,
eauger@redhat.com, miguel.luis@oracle.com,
darren@os.amperecomputing.com, scott@os.amperecomputing.com
Subject: Re: [PATCH v2 2/2] KVM: arm64: timers: Save restore CVAL of a ptimer across guest entry and exits
Date: Mon, 18 Sep 2023 12:29:26 +0100 [thread overview]
Message-ID: <8634zben3d.wl-maz@kernel.org> (raw)
In-Reply-To: <ec322123-bfe7-6019-7f35-de326ee7b6c3@os.amperecomputing.com>
On Fri, 15 Sep 2023 10:57:46 +0100,
Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com> wrote:
>
> This patch did not work.
> After adding changes as in below diff, it is started working.
Thanks for looking into this.
>
> diff --git a/arch/arm64/kvm/hyp/vhe/switch.c
> b/arch/arm64/kvm/hyp/vhe/switch.c
> index b0b07658f77d..91d2cfb03e26 100644
> --- a/arch/arm64/kvm/hyp/vhe/switch.c
> +++ b/arch/arm64/kvm/hyp/vhe/switch.c
> @@ -117,7 +117,7 @@ static void __activate_traps(struct kvm_vcpu *vcpu)
> val = __vcpu_sys_reg(vcpu, CNTHP_CVAL_EL2);
>
> if (map.direct_ptimer) {
> - write_sysreg_s(val, SYS_CNTP_CVAL_EL0);
> + write_sysreg_el0(val, SYS_CNTP_CVAL);
Duh, of course. Silly me.
> isb();
> }
> }
> @@ -161,8 +161,6 @@ static void __deactivate_traps(struct kvm_vcpu *vcpu)
>
> ___deactivate_traps(vcpu);
>
> - write_sysreg(HCR_HOST_VHE_FLAGS, hcr_el2);
> -
> if (has_cntpoff()) {
> struct timer_map map;
> u64 val, offset;
> @@ -173,7 +171,7 @@ static void __deactivate_traps(struct kvm_vcpu *vcpu)
> * We're exiting the guest. Save the latest CVAL value
> * to memory and apply the offset now that TGE is set.
> */
> - val = read_sysreg_s(SYS_CNTP_CVAL_EL0);
> + val = read_sysreg_el0(SYS_CNTP_CVAL);
> if (map.direct_ptimer == vcpu_ptimer(vcpu))
> __vcpu_sys_reg(vcpu, CNTP_CVAL_EL0) = val;
> if (map.direct_ptimer == vcpu_hptimer(vcpu))
> @@ -182,12 +180,13 @@ static void __deactivate_traps(struct kvm_vcpu *vcpu)
> offset = read_sysreg_s(SYS_CNTPOFF_EL2);
>
> if (map.direct_ptimer && offset) {
> - offset = read_sysreg_s(SYS_CNTPOFF_EL2);
> - write_sysreg_s(val + offset, SYS_CNTP_CVAL_EL0);
> + write_sysreg_el0(val + offset, SYS_CNTP_CVAL);
> isb();
> }
> }
>
> + write_sysreg(HCR_HOST_VHE_FLAGS, hcr_el2);
Why moving the HCR_EL2 update? I don't grok what it changes. Or is it
that you end-up with spurious interrupts because your GIC is slow to
retire interrupts that are transiently pending?
Thanks,
M.
--
Without deviation from the norm, progress is not possible.
WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
Cc: linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev,
linux-arm-kernel@lists.infradead.org, Christoffer.Dall@arm.com,
eauger@redhat.com, miguel.luis@oracle.com,
darren@os.amperecomputing.com, scott@os.amperecomputing.com
Subject: Re: [PATCH v2 2/2] KVM: arm64: timers: Save restore CVAL of a ptimer across guest entry and exits
Date: Mon, 18 Sep 2023 12:29:26 +0100 [thread overview]
Message-ID: <8634zben3d.wl-maz@kernel.org> (raw)
In-Reply-To: <ec322123-bfe7-6019-7f35-de326ee7b6c3@os.amperecomputing.com>
On Fri, 15 Sep 2023 10:57:46 +0100,
Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com> wrote:
>
> This patch did not work.
> After adding changes as in below diff, it is started working.
Thanks for looking into this.
>
> diff --git a/arch/arm64/kvm/hyp/vhe/switch.c
> b/arch/arm64/kvm/hyp/vhe/switch.c
> index b0b07658f77d..91d2cfb03e26 100644
> --- a/arch/arm64/kvm/hyp/vhe/switch.c
> +++ b/arch/arm64/kvm/hyp/vhe/switch.c
> @@ -117,7 +117,7 @@ static void __activate_traps(struct kvm_vcpu *vcpu)
> val = __vcpu_sys_reg(vcpu, CNTHP_CVAL_EL2);
>
> if (map.direct_ptimer) {
> - write_sysreg_s(val, SYS_CNTP_CVAL_EL0);
> + write_sysreg_el0(val, SYS_CNTP_CVAL);
Duh, of course. Silly me.
> isb();
> }
> }
> @@ -161,8 +161,6 @@ static void __deactivate_traps(struct kvm_vcpu *vcpu)
>
> ___deactivate_traps(vcpu);
>
> - write_sysreg(HCR_HOST_VHE_FLAGS, hcr_el2);
> -
> if (has_cntpoff()) {
> struct timer_map map;
> u64 val, offset;
> @@ -173,7 +171,7 @@ static void __deactivate_traps(struct kvm_vcpu *vcpu)
> * We're exiting the guest. Save the latest CVAL value
> * to memory and apply the offset now that TGE is set.
> */
> - val = read_sysreg_s(SYS_CNTP_CVAL_EL0);
> + val = read_sysreg_el0(SYS_CNTP_CVAL);
> if (map.direct_ptimer == vcpu_ptimer(vcpu))
> __vcpu_sys_reg(vcpu, CNTP_CVAL_EL0) = val;
> if (map.direct_ptimer == vcpu_hptimer(vcpu))
> @@ -182,12 +180,13 @@ static void __deactivate_traps(struct kvm_vcpu *vcpu)
> offset = read_sysreg_s(SYS_CNTPOFF_EL2);
>
> if (map.direct_ptimer && offset) {
> - offset = read_sysreg_s(SYS_CNTPOFF_EL2);
> - write_sysreg_s(val + offset, SYS_CNTP_CVAL_EL0);
> + write_sysreg_el0(val + offset, SYS_CNTP_CVAL);
> isb();
> }
> }
>
> + write_sysreg(HCR_HOST_VHE_FLAGS, hcr_el2);
Why moving the HCR_EL2 update? I don't grok what it changes. Or is it
that you end-up with spurious interrupts because your GIC is slow to
retire interrupts that are transiently pending?
Thanks,
M.
--
Without deviation from the norm, progress is not possible.
_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next prev parent reply other threads:[~2023-09-18 11:29 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-09-04 11:42 [PATCH v2 0/2] Avoid spurious ptimer interrupts for non-zero cntpoff Ganapatrao Kulkarni
2023-09-04 11:42 ` Ganapatrao Kulkarni
2023-09-04 11:42 ` [PATCH v2 1/2] KVM: arm64: timers: Move helper has_cntpoff to a header file Ganapatrao Kulkarni
2023-09-04 11:42 ` Ganapatrao Kulkarni
2023-09-04 11:42 ` [PATCH v2 2/2] KVM: arm64: timers: Save restore CVAL of a ptimer across guest entry and exits Ganapatrao Kulkarni
2023-09-04 11:42 ` Ganapatrao Kulkarni
2023-09-10 11:45 ` Marc Zyngier
2023-09-10 11:45 ` Marc Zyngier
2023-09-15 9:57 ` Ganapatrao Kulkarni
2023-09-15 9:57 ` Ganapatrao Kulkarni
2023-09-18 11:29 ` Marc Zyngier [this message]
2023-09-18 11:29 ` Marc Zyngier
2023-09-19 6:15 ` Ganapatrao Kulkarni
2023-09-19 6:15 ` Ganapatrao Kulkarni
2023-09-24 9:48 ` Marc Zyngier
2023-09-24 9:48 ` Marc Zyngier
2023-09-25 5:35 ` Ganapatrao Kulkarni
2023-09-25 5:35 ` Ganapatrao Kulkarni
2023-09-25 5:40 ` Ganapatrao Kulkarni
2023-09-25 5:40 ` Ganapatrao Kulkarni
2023-10-10 4:54 ` Ganapatrao Kulkarni
2023-10-10 4:54 ` Ganapatrao Kulkarni
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=8634zben3d.wl-maz@kernel.org \
--to=maz@kernel.org \
--cc=Christoffer.Dall@arm.com \
--cc=darren@os.amperecomputing.com \
--cc=eauger@redhat.com \
--cc=gankulkarni@os.amperecomputing.com \
--cc=kvmarm@lists.linux.dev \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miguel.luis@oracle.com \
--cc=scott@os.amperecomputing.com \
/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.