[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20241209053201.339939-1-gankulkarni@os.amperecomputing.com>
Date: Sun, 8 Dec 2024 21:32:01 -0800
From: Ganapatrao Kulkarni <gankulkarni@...amperecomputing.com>
To: kvmarm@...ts.cs.columbia.edu,
linux-arm-kernel@...ts.infradead.org,
linux-kernel@...r.kernel.org
Cc: maz@...nel.org,
oliver.upton@...ux.dev,
christoffer.dall@....com,
suzuki.poulose@....com,
will@...nel.org,
catalin.marinas@....com,
coltonlewis@...gle.com,
joey.gouly@....com,
yuzenghui@...wei.com,
darren@...amperecomputing.com,
gankulkarni@...amperecomputing.com,
vishnu@...amperecomputing.com
Subject: [PATCH] KVM: arm64: nv: Set ISTATUS for emulated timers, If timer expired
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@...amperecomputing.com>
Signed-off-by: Vishnu Pajjuri <vishnu@...amperecomputing.com>
Signed-off-by: Ganapatrao Kulkarni <gankulkarni@...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
Powered by blists - more mailing lists