linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
Cc: kvmarm <kvmarm@lists.linux.dev>,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, oliver.upton@linux.dev,
	christoffer.dall@arm.com, suzuki.poulose@arm.com,
	will@kernel.org, catalin.marinas@arm.com, coltonlewis@google.com,
	joey.gouly@arm.com, yuzenghui@huawei.com,
	darren@os.amperecomputing.com, vishnu@os.amperecomputing.com
Subject: Re: [PATCH] KVM: arm64: nv: Set ISTATUS for emulated timers, If timer expired
Date: Mon, 09 Dec 2024 15:23:27 +0000	[thread overview]
Message-ID: <8634iwubgw.wl-maz@kernel.org> (raw)
In-Reply-To: <865xntt2kv.wl-maz@kernel.org>

On Mon, 09 Dec 2024 13:20:48 +0000,
Marc Zyngier <maz@kernel.org> wrote:
> 
> So here's my current guess, since you don't give me the needed
> information. For what you describe to happen, I can only see two
> possibilities:
> 
> - either your HW doesn't have FEAT_ECV, in which case the guest
>   directly reads from memory
> 
> - or you are running with something like this patch [1], and we serve
>   the guest by reading from memory very early, without returning to
>   the bulk of the emulation code
> 
> In either case, we only publish the updated status if the current IRQ
> state is different from the computed output of the timer while
> performing the emulation.
> 
> So if you were writing back a status bit set to 0 while the interrupt
> was already pending, we'd deliver an interrupt, but not recompute the
> status. The guest would consider the interrupt as spurious, not touch
> the timer, and we'd never make forward progress. Rinse, repeat.
> 
> Assuming I got the analysis right, it would only be a matter of
> hoisting the publication of the status into timer_emulate(), so that
> it is made up to date on load.
> 
> Please give the fixup below a go.

Plus this on top for a good measure:

diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c
index 91bda986c344b..c71193a7bb9c5 100644
--- a/arch/arm64/kvm/arch_timer.c
+++ b/arch/arm64/kvm/arch_timer.c
@@ -968,9 +968,6 @@ void kvm_timer_sync_nested(struct kvm_vcpu *vcpu)
 	 * which allows trapping of the timer registers even with NV2.
 	 * Still, this is still worse than FEAT_NV on its own. Meh.
 	 */
-	if (cpus_have_final_cap(ARM64_HAS_ECV) || !is_hyp_ctxt(vcpu))
-		return;
-
 	if (!vcpu_el2_e2h_is_set(vcpu)) {
 		/*
 		 * A non-VHE guest hypervisor doesn't have any direct access
diff --git a/arch/arm64/kvm/arm.c b/arch/arm64/kvm/arm.c
index ff62b8b55b46e..1b8bb30dbb2ff 100644
--- a/arch/arm64/kvm/arm.c
+++ b/arch/arm64/kvm/arm.c
@@ -1257,7 +1257,7 @@ int kvm_arch_vcpu_ioctl_run(struct kvm_vcpu *vcpu)
 		if (unlikely(!irqchip_in_kernel(vcpu->kvm)))
 			kvm_timer_sync_user(vcpu);
 
-		if (vcpu_has_nv(vcpu))
+		if (is_hyp_ctxt(vcpu))
 			kvm_timer_sync_nested(vcpu);
 
 		kvm_arch_vcpu_ctxsync_fp(vcpu);


	M.

-- 
Without deviation from the norm, progress is not possible.


  reply	other threads:[~2024-12-09 15:24 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-09  5:32 [PATCH] KVM: arm64: nv: Set ISTATUS for emulated timers, If timer expired Ganapatrao Kulkarni
2024-12-09  9:54 ` Marc Zyngier
2024-12-09 12:25   ` Ganapatrao Kulkarni
2024-12-09 13:20     ` Marc Zyngier
2024-12-09 15:23       ` Marc Zyngier [this message]
2024-12-09 15:39       ` Ganapatrao Kulkarni
2024-12-09 15:52         ` Marc Zyngier
2024-12-09 16:46         ` Eric Auger
2024-12-09 17:30           ` Marc Zyngier
2024-12-09 17:34             ` Eric Auger
2024-12-19  9:30               ` Ganapatrao Kulkarni
2024-12-19 12:23                 ` Marc Zyngier
2025-01-14 13:12                 ` Eric Auger
2025-01-14 14:38                   ` Marc Zyngier
2025-01-14 14:57                     ` Eric Auger
2025-01-14 15:52                       ` Marc Zyngier
2025-01-16 17:52                         ` Eric Auger
2025-01-16 18:25                           ` Marc Zyngier
2025-02-07 17:45                           ` Marc Zyngier
2025-02-07 18:09                             ` Oliver Upton
2025-02-07 18:38                               ` Marc Zyngier
2025-02-07 19:08                                 ` Oliver Upton
2025-02-10 18:26                                 ` Eric Auger
2025-02-11 19:20                                   ` Marc Zyngier
2025-02-15 17:50                                   ` Marc Zyngier
2025-02-18  7:33                                     ` Ganapatrao Kulkarni
2025-02-18 16:33                                       ` Marc Zyngier
2025-02-18 21:24                                       ` Marc Zyngier
2025-02-20  6:10                                         ` Ganapatrao Kulkarni
2025-02-10 13:18                             ` Eric Auger
2024-12-10 12:48       ` Ganapatrao Kulkarni
2024-12-09 19:36 ` kernel test robot

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=8634iwubgw.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=catalin.marinas@arm.com \
    --cc=christoffer.dall@arm.com \
    --cc=coltonlewis@google.com \
    --cc=darren@os.amperecomputing.com \
    --cc=gankulkarni@os.amperecomputing.com \
    --cc=joey.gouly@arm.com \
    --cc=kvmarm@lists.linux.dev \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=oliver.upton@linux.dev \
    --cc=suzuki.poulose@arm.com \
    --cc=vishnu@os.amperecomputing.com \
    --cc=will@kernel.org \
    --cc=yuzenghui@huawei.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).