From: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
To: kvmarm@lists.cs.columbia.edu,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org
Cc: maz@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,
gankulkarni@os.amperecomputing.com,
vishnu@os.amperecomputing.com
Subject: [PATCH] KVM: arm64: nv: Set ISTATUS for emulated timers, If timer expired
Date: Sun, 8 Dec 2024 21:32:01 -0800 [thread overview]
Message-ID: <20241209053201.339939-1-gankulkarni@os.amperecomputing.com> (raw)
During automated testing of Nested Virtualization using avocado-vt,
it has been observed that during some boot test iterations,
the Guest-Hypervisor boot was getting crashed with a
synchronous exception while it is still booting EDK2.
The test is launching Multiple instances of Guest-Hypervisor boot
and while booting, QEMU monitor issued the command "info register"
at regular intervals to take a register dump. To execute this
command, QEMU stops the run and does the register read of various
registers. While resuming the run, the function kvm_arm_timer_write()
writes back the saved CNTV_CTL_EL0 register with ISTATUS cleared always
and resulting in the loss of pending interrupt for emulated timers.
In hardware based timers, ISTATUS is a RO/WI bit and gets set by the
h/w, if the condition is still met. However, in Nested-Virtualization
case, the Guest-Hypervisor's EDK2 is using an emulated virtual timer
and losing ISTATUS state and the interrupt forever.
Adding fix in kvm_arm_timer_write to set ISTATUS for emulated
timers, if the timer expired already.
Fixes: 81dc9504a700 ("KVM: arm64: nv: timers: Support hyp timer emulation")
Co-developed-by: Vishnu Pajjuri <vishnu@os.amperecomputing.com>
Signed-off-by: Vishnu Pajjuri <vishnu@os.amperecomputing.com>
Signed-off-by: Ganapatrao Kulkarni <gankulkarni@os.amperecomputing.com>
---
arch/arm64/kvm/arch_timer.c | 11 ++++++++++-
1 file changed, 10 insertions(+), 1 deletion(-)
diff --git a/arch/arm64/kvm/arch_timer.c b/arch/arm64/kvm/arch_timer.c
index 1215df590418..aca58113d790 100644
--- a/arch/arm64/kvm/arch_timer.c
+++ b/arch/arm64/kvm/arch_timer.c
@@ -1199,7 +1199,16 @@ static void kvm_arm_timer_write(struct kvm_vcpu *vcpu,
break;
case TIMER_REG_CTL:
- timer_set_ctl(timer, val & ~ARCH_TIMER_CTRL_IT_STAT);
+ struct timer_map map;
+
+ val &= ~ARCH_TIMER_CTRL_IT_STAT;
+ get_timer_map(vcpu, &map);
+ /* Set ISTATUS bit for emulated timers, if timer expired. */
+ if (timer == map.emul_vtimer || timer == map.emul_ptimer) {
+ if (!kvm_timer_compute_delta(timer))
+ val |= ARCH_TIMER_CTRL_IT_STAT;
+ }
+ timer_set_ctl(timer, val);
break;
case TIMER_REG_CVAL:
--
2.47.0
next reply other threads:[~2024-12-09 5:34 UTC|newest]
Thread overview: 32+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-09 5:32 Ganapatrao Kulkarni [this message]
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
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=20241209053201.339939-1-gankulkarni@os.amperecomputing.com \
--to=gankulkarni@os.amperecomputing.com \
--cc=catalin.marinas@arm.com \
--cc=christoffer.dall@arm.com \
--cc=coltonlewis@google.com \
--cc=darren@os.amperecomputing.com \
--cc=joey.gouly@arm.com \
--cc=kvmarm@lists.cs.columbia.edu \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=maz@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
all inboxes | Powered by JetHome®