All of lore.kernel.org
 help / color / mirror / Atom feed
From: Helge Deller <deller@kernel.org>
To: qemu-devel@nongnu.org
Cc: Keith Monahan <keith@techtravels.org>,
	Helge Deller <deller@gmx.de>,
	Richard Henderson <richard.henderson@linaro.org>
Subject: [PULL 1/4] target/hppa: clear EIRR under the BQL and keep the interval timer matching
Date: Thu, 19 Nov 2026 23:47:41 +0100	[thread overview]
Message-ID: <20261119224744.31309-2-deller@kernel.org> (raw)
In-Reply-To: <20261119224744.31309-1-deller@kernel.org>

From: Keith Monahan <keith@techtravels.org>

An unlocked EIRR clear could drop a tick set by the main loop thread,
leaving the guest clock dead. HP-UX 10.20 installs wedged this way.

Signed-off-by: Keith Monahan <keith@techtravels.org>
Signed-off-by: Helge Deller <deller@gmx.de>
---
 target/hppa/int_helper.c | 23 ++++++++++++++++++++++-
 1 file changed, 22 insertions(+), 1 deletion(-)

diff --git a/target/hppa/int_helper.c b/target/hppa/int_helper.c
index 598d1c6cef..da9c7c6457 100644
--- a/target/hppa/int_helper.c
+++ b/target/hppa/int_helper.c
@@ -25,6 +25,7 @@
 #include "hw/core/cpu.h"
 #include "hw/hppa/hppa_hardware.h"
 #include "qemu/plugin.h"
+#include "qemu/timer.h"
 
 static void eval_interrupt(HPPACPU *cpu)
 {
@@ -78,14 +79,34 @@ const MemoryRegionOps hppa_io_eir_ops = {
 
 void hppa_cpu_alarm_timer(void *opaque)
 {
+    HPPACPU *cpu = opaque;
+
     /* Raise interrupt 0.  */
     io_eir_write(opaque, 0, 0, 4);
+
+    /*
+     * Re-arm the alarm one counter wrap later.  The hardware compares CR16
+     * against a free running 32-bit counter, so the match recurs every
+     * 2^32 counts, which is 2^34 ns at the 250 MHz shown to the guest.
+     * This brings the model closer to that and limits a lost tick to a
+     * 17 s stall instead of a dead clock.
+     */
+    cpu->env.cr[CR_IT] += 1ULL << 34;
+    timer_mod(cpu->alarm_timer, cpu->env.cr[CR_IT]);
 }
 
 void HELPER(write_eirr)(CPUHPPAState *env, target_ulong val)
 {
-    env->cr[CR_EIRR] &= ~val;
+    /*
+     * Clear EIRR under the BQL.  io_eir_write() sets EIRR bits from the main
+     * loop thread for the interval timer and for device interrupts, and it
+     * holds the BQL.  This helper runs in the vCPU thread, so an unlocked
+     * read-modify-write here drops any bit set between the load and the
+     * store.  A dropped interval timer bit is never re-armed and the guest
+     * clock stops, which is how HP-UX 10.20 installs wedged under load.
+     */
     bql_lock();
+    env->cr[CR_EIRR] &= ~val;
     eval_interrupt(env_archcpu(env));
     bql_unlock();
 }
-- 
2.54.0



  reply	other threads:[~2026-11-19 22:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 22:47 [PULL 0/4] Hp715 fixes patches Helge Deller
2026-11-19 22:47 ` Helge Deller [this message]
2026-11-19 22:47 ` [PULL 2/4] target/hppa: re-arm the interval timer after loadvm Helge Deller
2026-11-19 22:47 ` [PULL 3/4] Revert "target/hppa: Move emulated power button into CPU I/O region" Helge Deller
2026-11-19 22:47 ` [PULL 4/4] hw/hppa: preload a BTLB entry for the soft power button page Helge Deller
2026-11-20 19:43 ` [PULL 0/4] Hp715 fixes patches Richard Henderson

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=20261119224744.31309-2-deller@kernel.org \
    --to=deller@kernel.org \
    --cc=deller@gmx.de \
    --cc=keith@techtravels.org \
    --cc=qemu-devel@nongnu.org \
    --cc=richard.henderson@linaro.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.